FErase Function | |
Delete a file from disk.
Namespace:
XSharp.Core
Assembly:
XSharp.Core (in XSharp.Core.dll) Version: 2.19
Syntax FUNCTION FErase(
cFileName AS STRING
) AS LOGIC
public static bool FErase(
string cFileName
)
Request Example
View SourceParameters
- 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:
Logic
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:
1AEval(Directory("*.bak"), {|aFile|;
2 FErase(aFile[F_NAME])})
This example erases a file and displays a message if the operation fails:
1IF .NOT. FErase("afile.txt")
2 ? DOSErrString(FError())
3ENDIF
See Also