Xbasic

FILE.REMOVE Function

Syntax

Result as N = FILE.Remove(C file_name)

Arguments

file_nameCharacter

The name of the file.

Returns

ResultNumeric

Returns zero (0) if the operation was successful.

Description

Remove a file.

Discussion

The FILE.REMOVE() method erases a particular file, removing it from the disk. You must supply an existing Filename. The FILE.REMOVE() method looks for the file in the default directory if no path is specified in the Filename. To erase a table or set, it is better to use the TABLE.ERASE() method. This will automatically remove support files, such as the data dictionary and memo field file.

The method causes an error if the file does not exist.

Example

This script will delete the file you select.

filename = ui_get_file("Delete File", "All Files (*.*)", "", "X")
if (filename = "") then
    end
end if
if (FILE.exists(filename)) then
    FILE.remove(filename)
end if

See Also