Click or drag to resize

FErase Function

Delete a file from disk.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.4a
Syntax
 FUNCTION FErase(
	cFileName AS STRING
) AS LOGIC
View Source

Parameters

cFileName
Type: String
The file name, including an optional drive, directory, and extension.  SetDefault() and SetPath() settings are ignored; the Windows default is used unless you specify a drive and directory as part of the file name.  No extension is assumed.

Return Value

Type: Boolean
TRUE if the operation succeeds; otherwise, FALSE.  In the case of a failure, FError() can be used to determine the specific error.
Remarks
FErase() is the same as the ERASE command but returns a value and can be specified within an expression. Warning!  Files must be closed before removing them with FErase().
Examples
This example deletes a set of files matching a wildcard pattern:
X#
1AEval(Directory("*.bak"), {|aFile|;
2                FErase(aFile[F_NAME])})
This example erases a file and displays a message if the operation fails:
X#
1IF .NOT. FErase("afile.txt")
2    ? DOSErrString(FError())
3ENDIF
See Also