Erases a file from a disk.
DELETE FILE [FileName | ?] [RECYCLE] |
Parameters
- FileName
-
Specifies the file to delete.
Tip: FileName can contain wildcard characters such as * and ?. For example, to delete backup files with the extension .bak in the current directory, issue DELETE FILE *.BAK. If FileName contains spaces, enclose the entire file name in quotes.
- ?
- Displays the Delete dialog box so you can choose a file to delete.
- RECYCLE
-
Specifies that the file is not immediately deleted from disk and is placed in the Windows Recycle Bin.
Caution: Any file deleted with this command cannot be retrieved. Even when the SET SAFETY command is set to ON, you are not warned before the file is deleted.
Remarks
The file you want to delete cannot be open when DELETE FILE is issued. The file name must include a path if it is on a different drive or volume, or in a different directory from the default. A file name extension must be included.
If the file you want to delete represents a table that is part of a database, you need to remove the table from the database before deleting the file. You can use the REMOVE TABLE command before using the DELETE FILE command. If you delete a table that has an associated .FPT memo file, be sure to delete the memo file.
This command does not generate an error if the specified file does not exist.
The DELETE FILE command is the same as the ERASE command.
Example
In the following example, the structure of Customer.dbf and all records in which the country equals USA are copied to a table named backup
. The data in backup
is then copied to a text file, temp
, which is opened and then deleted once closed.
В | Copy Code |
---|---|
CLOSE DATABASES OPEN DATABASE (HOME(2) + 'Data\testdata') USE customer && Opens Customer table COPY STRUCTURE TO backup USE backup APPEND FROM customer FOR country = 'USA' COPY TO temp TYPE DELIMITED WAIT WINDOW 'Press Esc to close and erase temp.txt' NOWAIT MODIFY FILE temp.txt NOEDIT DELETE FILE temp.txt ? IIF(FILE('temp.txt'),'File not deleted','File deleted') USE DELETE FILE backup.dbf |