$fileexists
Returns a value that indicates whether the specified file or directory exists.
$fileexists(FilePath | DirPath)
Example: if ($fileexists(vFile) = 1) ...
Parameters
| Parameter | Data Type | Description |
|---|---|---|
| FilePath | String | File name, optionally preceded by the path to the file. Must not end with a directory separator. |
| DirPath | String | Directory name, optionally preceded by the path to the directory. Must end with a directory separator |
Return Values
| Value | Meaning |
|---|---|
| 0 | File or directory does not exist |
| 1 | File exists |
| 2 | Directory exists |
| 4 | File exists in a ZIP archive |
| 5 | Directory exists in a ZIP archive |
| Value | Error constant | Meaning |
|---|---|---|
0
|
|
Successful |
-13
|
<UIOSERR_OS_COMMAND>
|
An error occurred while trying to perform
the OS command. Set /pri=64 to display the exact error in the message frame. |
Use
Allowed in all Uniface component types.
Specifying File and Directory Paths
- Each specification can be a string, a field (or indirect reference to a field), a variable, or a function that evaluates to a string.
- The total length of any path (or file name or directory name) must not exceed 255 bytes.
- Valid generic directory separators are the
backward slash (
\), the forward slash (/) , and the period (.) in combination with square brackets ([a.b]). These are translated to the platform-specific separators. - No wildcards are allowed in any path, except
for $ldirlist and $dirlist, which allows the Uniface
wildcards
?(GOLD ?) and*(GOLD *) in the directory name, for exampleab?, or in its suffix, for exampleabc\*.txt.
For more information, see Syntax of File and Directory Names.
Checking if a File Exists
The following example checks whether the file test.txt exists in the directory sub1dir and, if so, loads it:
vFile = "sub1dir\test.txt" if ($fileexists(vFile) = 1) fileload vFile , vContent endif