FERASE() Delete a file from disk ------------------------------------------------------------------------------ Syntax FERASE(<cFile>) --> nSuccess Arguments <cFile> is the name of the file to be deleted from disk, including extension, optionally preceded by a drive and/or path specification. Returns FERASE() returns -1 if the operation fails and zero if it succeeds. In the case of a failure, FERROR() can be used to determine the nature of the error. Description FERASE() is a file function that deletes a specified file from disk. FERASE() is the same as the ERASE command but returns a value and can be specified within an expression. When FERASE() is called, <cFile> is deleted from disk only if found in the current DOS directory or in the directory explicitly specified as part of the file name. Like the other file functions and commands, FERASE() does not use either SET DEFAULT or SET PATH to locate <cFile>. Warning! Files must be CLOSEd before removing them with FERASE(). Examples . This example deletes a set of files matching a wildcard pattern: #include "Directry.ch" AEVAL(DIRECTORY("*.BAK"), { |aFile| ; FERASE(aFile[F_NAME]) }) . This example erases a file and displays a message if the operation fails: IF FERASE("AFile.txt") == -1 ? "File erase error:", FERROR() BREAK ENDIF Files Library is CLIPPER.LIB.
See Also: CLOSE ERASE FERROR() FRENAME() RENAME
Pingback: C5_RENAME | Viva Clipper !