xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

File()

Checks for the existence of a file in the default directory or path

Syntax

File( <cFileSpec> ) --> lExists

Arguments

<cFileSpec>
This is a character string containing the file specification to search for. It can include the wildcard characters (* and ?) and/or drive and directory information. If a complete file name isgiven, it must include a file extension.

Return

The function returns .T. (true) if a match is found for <cFileSpec>, otherwise .F. (false).

Description

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().

Info

See also:CurDir(), Directory(), IsDirectory(), SET DEFAULT, SET PATH
Category: File functions
Source:rtl\filehb.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe