Function group | Execute on client | Platform(s) |
---|---|---|
FileOps | NO | All |
FileOps.$deletefile(cPath[deleteContents=kFalse,recursive=kFalse])
Deletes the file or folder named cPath. Pathnames can be over 255 characters. The optional parameters deleteContents and recursive allow you to delete the contents of a folder (both default to kFalse, if omitted).
Files deleted with $deletefile() are not moved into the Recycled bin or Trash can, they are deleted irreversibly. You can delete a folder with $deletefile(), but only if it is empty.
The combination of the parameters has the following results:
FileOps.$deletefile(cPath, kFalse, kFalse)
(same as if deleteContents and recursive are omitted) if cPath is a folder, the folder will be deleted only if empty, that if no files or directories are present in the folder. On macOS, the function checks if the only file is .DS_Store and will delete the folder in that case. If there are hidden files in the folder, the folder and the hidden files will not be deleted.
FileOps.$deletefile(cPath, [kTrue, kFalse])
if cPath is a folder, all files inside the folder if deleteContents is true, but any subfolders will not be deleted. Furthermore, if the folder is empty, the folder will not be deleted.
FileOps.$deletefile(cPath, kFalse, kTrue)
if cPath is a folder, it will be deleted only if empty. If there are any contents, those will not be deleted as deleteContents is kFalse, even if recursive is kTrue.
FileOps.$deletefile(cPath, kTrue, kTrue)
if cPath is a folder, it will be wiped off the disk with its contents, if any are present.
FileOps.$deletefile(cFilePath)
if cPath is a file, the file will be removed regardless of the deleteContents or recursive values - the deleteContents and recursive parameters do not impact the behavior of deleting files, only the behavior of deleting folders.
The function returns an error code, or zero if successful: see the FileOps function error codes.
Do FileOps.$deletefile('c:\omnis\examples\extcomp\test1.txt') Returns lError
# deletes 'test1.txt' from 'c:\omnis\examples\extcomp'
Do FileOps.$changeworkingdir('c:\omnis') Returns lError
Do FileOps.$deletefile('test2.txt') Returns lError
# deletes 'test2.txt' at the current folder 'c:\omnis'
Do FileOps.$deletefile('c:\omnis\examples\extcomp\clock') Returns lError
# deletes the 'clock' folder if empty