Xbasic
FILE.EXISTS Function
Syntax
File_Found_Flag as L = FILE.Exists(C filename)
Arguments
- filenameCharacter
The name of the file.
Returns
- File_Found_FlagLogical
Returns .T. if the file exists, otherwise .F.
Description
The FILE.EXISTS() method determines if a file or directory exists on disk. A logical result of TRUE (.T.) is returned if the supplied Filename is found.
Example
This script checks to see if the defaults file already exists. If not, the defaults file is created.
filename = "c:\a5\defaults.txt"
result = FILE.exists(filename)
if result = .F. then
answer = ui_msg_box("","File does not exist. Create a new one? ", UI_YES_NO)
'user answered "No".
if answer = UI_NO_SELECTED then
end
end if
file_pointer = FILE.create(filename, FILE_RW_EXCLUSIVE)
file_pointer.write("Defaults:")
else
end
end if
file_pointer.flush()
file_pointer.close()See Also