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: On UNIX, if a file to be deleted is a symbolic link, FILE_DELETE deletes the link itself, and not the file that the link points to.
Note: The FILE_DELETE procedure will not ask for confirmation before deleting files. If you are writing an application, you may want to use the DIALOG_MESSAGE function to confirm file deletion.
In this example, we remove an empty directory named moose:
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.
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.
Note: Recursive delete is a very powerful and useful operation. However, it is a relatively dangerous command with the ability to rapidly destroy a great deal of data. Once deleted, files cannot be recovered unless you have a separate backup, so a mistaken recursive delete can be very damaging. Be very careful to specify correct arguments to FILE_DELETE when using the RECURSIVE keyword.
By default, FILE_DELETE will permanently delete files. If the RECYCLE keyword is set, then FILE_DELETE will move files to the operating system's recycle (or trash) bin, so that the files can be recovered.
Note: This keyword is only available on Windows platforms. On other platforms this keyword will be quietly ignored and the files will be permanently deleted.
Note: FILE_DELETE will not ask for confirmation when deleting files, even if RECYCLE is set.
The VERBOSE keyword causes FILE_DELETE to issue an informative message for every file it deletes.
Added ALLOW_NONEXISTANT and VERBOSE keywords
|8.4||Added RECYCLE keyword|
This page has no user notes yet. Be the first one!