The FILE_DELETE procedure deletes a file or empty directory, if the process has the necessary permissions to remove the file as defined by the current operating system. FILE_CHMOD can be used to change file protection settings.
| Note |
The syntax used to specify directories for removal depends on the operating system in use, and is in general the same as you would use when issuing commands to the operating system command interpreter.
Microsoft Windows users must be careful to not specify a trailing backslash at the end of a specification. For example:
FILE_DELETE, 'c:\mydir\myfile'
and not:
FILE_DELETE, 'c:\mydir\myfile\'
FILE_DELETE, File1 [,... Filen] [, /ALLOW_NONEXISTENT] [, /NOEXPAND_PATH] [, /QUIET] [, /RECURSIVE] [, /VERBOSE]
A scalar or array of file or directory names to be deleted, one name per string element. Directories must be specified in the native syntax for the current operating system. See "Operating System Syntax" below for additional details.
If set, FILE_DELETE will quietly ignore attempts to delete a non-existent file. Other errors will still be reported. The QUIET keyword can be used instead to suppress all errors.
Set this keyword to cause FILE_DELETE to use the File argument exactly as specified, without applying the usual file path expansion.
FILE_DELETE will normally issue an error if it is unable to remove a requested file or directory. If QUIET is set, no error is issued and FILE_DELETE simply moves on to the next requested item.
By default, FILE_DELETE will refuse to delete directories that are not empty. If RECURSIVE is set, FILE_DELETE will instead quietly delete all files contained within that directory and any subdirectories below it, and then remove the directory itself.
| Warning |
The VERBOSE keyword causes FILE_DELETE to issue an informative message for every file it deletes.
In this example, we remove an empty directory named moose:
FILE_DELETE, 'moose'
Introduced: 5.4
ALLOW_NONEXISTENT and VERBOSE keywords added: 5.6