Skip to main content

DeleteFile

DeleteFile [/I/M=messageStr /P=pathName /Z ] [fileNameStr ]​

The DeleteFile operation deletes a file on disk.

Parameters​

fileNameStr can be a full path to the file to be deleted (in which case /P is not needed), a partial path relative to the folder associated with pathName, or the name of a file in the folder associated with pathName.

If Igor cannot determine the location of the file from fileNameStr and pathName, it displays a dialog allowing you to specify the file to be deleted.

If you use a full or partial path for either file, see Path Separators for details on forming the path.

Flags​

/IInteractive mode. The Open File dialog will display even if fileNameStr is specified and the file exists.
/M = messageStrSpecifies the prompt message in the Open File dialog.
/P = pathNameSpecifies the folder to look in for the file. pathName is the name of an existing symbolic path.
/Z[ = z ]Prevents procedure execution from aborting if it attempts to delete a file that does not exist. Use /Z if you want to handle this case in your procedures rather than having execution abort.
/Z=0:Same as no /Z.
/Z=1:Deletes a file only if it exists. /Z alone has the same effect as /Z=1.
/Z=2:Deletes a file if it exists or displays a dialog if it does not exist.

Variables​

The Delete operation returns information in the following variables:
V_flagSet to zero if the file was deleted, to -1 if the user cancelled the Open File dialog, and to some nonzero value if an error occurred, such as the specified file does not exist.
S_pathStores the full path to the file that was deleted. If an error occurred or if the user cancelled, it is set to an empty string.

See Also​

DeleteFolder, MoveFile, CopyFile, NewPath, Symbolic Paths