xHarbour Reference Documentation > Function Reference |
Checks for the existence of a file in the default directory or path
File( <cFileSpec> ) --> lExists
The function returns .T. (true) if a match is found for <cFileSpec>, otherwise .F. (false).
The File() function is used to check if a file exists that matches the file specification <cFileSpec>. When <cFileSpec> does not contain directory information, the function searches directories in the following order:
1. | the current directory. |
2. | the directory set with SET DEFAULT. |
3. | the directories listed in the SET PATH setting. |
Directories defined with environment variables of the operating system are not searched for <cFileSpec>. In addition, hidden or system files are not recognized by File().
See also: | CurDir(), Directory(), IsDirectory(), SET DEFAULT, SET PATH |
Category: | File functions |
Source: | rtl\filehb.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example shows the dependency between File() and the // SET PATH and SET DEFAULT settings. PROCEDURE Main ? File( "Customer.dbf" ) // result: .F. ? File( "\xhb\apps\data\Customerdbf") // result: .T. SET PATH TO \xhb\apps\data ? File( "Customer.dbf" ) // result: .T. SET PATH TO SET DEFAULT TO \xhb\apps\data ? File( "Customer.dbf" ) // result: .T. ? File( "*.cdx") // result: .T. RETURN
http://www.xHarbour.com