LOCFILE( ) Function
Locates a file on disk and returns the file name with its path.
LOCFILE(cFileName [, cFileExtensions] [, cFileNameCaption])
Return Values
Character
Parameters
cFileName
Specifies the name of the file to locate. If cFileName includes only a file name, LOCFILE( ) searches the Visual FoxPro default directory or folder first. If the file isn't found in the default directory or folder, the Microsoft Visual FoxPro path is then searched. Use SET PATH to specify the Visual FoxPro path.If cFileName includes a path and a file name, the specified location is searched. If the file can't be found in the specified location, LOCFILE( ) searches the Visual FoxPro default directory or folder and then the Visual FoxPro path.
If the file is located, LOCFILE( ) returns the file name and path.
cFileExtensions
Specifies file extensions for the file to locate. If the file name you specify with cFileName doesn't include an extension, Visual FoxPro applies the file extensions listed in cFileExtensions to the file name and searches for the file again.cFileExtensions also specifies the file name extensions of the files displayed in the Open dialog box when the file you specified can't be located.
cFileExtensions can take a variety of forms:
If cFileExtensions contains a single extension (for example, PRG), only files with that extension are displayed.
cFileExtensions can also contain wildcards (* and ?). All files with extensions that meet the wildcard criteria are displayed. For example, if cFileExtensions is ?X?, all files with the extension .fxp, .exe, or .txt are displayed.
In Visual FoxPro for Windows, cFileExtensions can contain a file description followed by a file extension or a list of file extensions separated with commas. The file description appears in the Files of Type list box. Separate the file description from the file extension or list of file extensions with a colon (:). Separate multiple file descriptions and their file extensions with a semicolon (;).
For example, if cFileExtensions is "Text:TXT" the file description "Text" appears in the Files of Type list box and all files with a .txt extension are displayed.
If cFileExtensions is "Tables:DBF; Files:TXT,BAK" the file descriptions "Tables" and "Files" appear in the Files of Type list box. When "Tables" is chosen from the Files of Type list box, all files with a .dbf extension are displayed. When "Files" is chosen from the Files of Type list box, all files with .txt and .bak extensions are displayed.
cFileNameCaption
Specifies the text you want to use to prompt the user. The text appears to the left of the textbox in which you enter the file name. If omitted, "File name:" is displayed.
For a list of Visual FoxPro file extensions and corresponding creator types, see the File Extensions and File Types online topic.
Remarks
The Open dialog box is displayed if the file can't be located in the default directory or folder, the Visual FoxPro path, or a specified location. The Open dialog box can be used to locate the file. When a file is chosen from the Open dialog box, the file name is returned with the file's path.
If you exit the Open dialog box by choosing Cancel, pressing ESC, or choosing Close from the Control menu, Visual FoxPro generates an error message and LOCFILE( ) doesn't return a value.
See Also
FILE( ) | GETFILE( ) | GETPICT( ) | PUTFILE( ) | SET PATH