共用方式為


DELETE FILE Command

Deletes a file from a disk.

DELETE FILE [FileName | ?] [RECYCLE]

Parameters

  • FileName
    Specifies the file to delete. 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 from which you can choose a file to delete.

  • RECYCLE
    Specifies that the file isn't immediately deleted from disk and is placed in the Windows Recycle Bin.

    Caution   Any file deleted with this command cannot be retrieved. Even if SET SAFETY is 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, and the file name extension must be included. The file name cannot contain wildcards.

Before you delete a table in a database, issue REMOVE TABLE with the table name to remove references to the table from the database. 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.

Example

In the following example, the structure of Customer.dbf and all records in which the country is 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 when it is closed.

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

See Also

ERASE | REMOVE TABLE | SET SAFETY