Export (0) Print
Expand All
Expand Minimize

ERASE Command

Deletes a file from disk.

Caution noteCaution

Exercise caution when using ERASE. Any file erased with this command cannot be retrieved. You are not warned before the file is erased, even if SET SAFETY is ON.


ERASE FileName | ? [RECYCLE]

Parameters

FileName

Specifies the file to be erased. Include the path with the file name if the file is on a different drive or directory from the current drive or directory.

FileName can contain wildcard characters such as * and ?, for example, to erase backup files with ERASE *.BAK. If FileName contains spaces, enclose the entire file name in quotes.

?

Displays the Delete dialog box, from which you can choose a file to erase.

RECYCLE

Specifies that the file is no't immediately deleted from disk, but rather placed in the Windows Recycle Bin.

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.

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
ERASE temp.txt
? IIF(FILE('temp.txt'),'File not deleted','File deleted')
USE
ERASE backup.dbf

Community Additions

ADD
Show:
© 2014 Microsoft