Does file exist

Command group Flag affected Reversible Execute on client Platform(s)
External commands YES NO NO Windows,Linux

Syntax

Does file exist (file|folder-nameReturns err-code

Description

Note: The flag is set according to whether Omnis was able to make a call to this external command.

This command returns kTrue if the specified file or folder exists, otherwise it returns kFalse. The file or folder must specify the full path.

When constructing the path to a file or folder, you can use sys(9) to insert the correct path delimiter for the current platform: \ (back-slash) on Windows, or / (forward-slash) for Unix and 64-bit macOS (: colon on 32-bit macOS). In addition, you can use sys(115) to return the full pathname of the folder containing the Omnis executable, including the terminating path separator, which might be useful to reference files in the Omnis tree.

See also, the command Test if file exists.

Example

Calculate lPathname as con(sys(115),'html',sys(9),'serverusagetask.htm')
Calculate lNewPath as con(sys(115),'html',sys(9),'serverusagetask2.htm')
Copy file (lPathname,lNewPath) Returns lErrCode ;; copies the file in lPathName to the filename contained in lNewPath
Does file exist (lNewPath) Returns lStatus ;; see if the file exists
If lStatus
  Delete file (lNewPath) Returns lErrCode ;; delete it
End If