CheckFile


The CheckFile methods checks the existence of specified file and optionally gets its attributes.
C++
long CheckFile(
  LPSTR FileName,                  // file name
  long *Attributes = NULL          // file attributes
);
long CheckFile(
  LPWSTR FileName,                 // file name
  long *Attributes = NULL          // file attributes
);
BASIC
CheckFile(
  FileName As Variant,             // file name
  Optional Attributes As Variant   // file attributes
) As Long

Parameters

FileName
C++
Pointer to buffer containing name of the file (must be NULL terminated).
BASIC
Variant containing name of the file.
Variant must be of String data type; it must not be an array.
Attributes
C++
Pointer to variable that receives file attributes.
BASIC
Variant that receives file attributes.
Variant type must be compatible with Long data type; it must not be an array.
Variant can be uninitialized; in such case it is converted to Long.

File attributes is a combination of the following values:

IXF_FILE_READONLY read-only file,
IXF_FILE_HIDDEN hidden file (not included in ordinary directory listing),
IXF_FILE_SYSTEM system file (used exclusively by the operating system),
IXF_FILE_ARCHIVE file marked to be archived,
IXF_FILE_NORMAL file with no special attributes;
never combined with other attributes,
IXF_FILE_TEMPORARY file for temporary usage (kept in memory).

Return Values

If specified file exists, the return value is 1. If file does not exist, the return value is 0.
If the method fails, the return value is failure code and error code is set. Call GetError to get error code.

Remarks

Method operates on files only - if FileName specifies existing directory, the return value is 0. FileName can be specified as either absolute or relative path.

Unicode version of the method should not be confused with Unicode system calls or Unicode text data. All versions of the method can be used on Unicode and non-Unicode systems depending on your needs. On Unicode systems, however, file is checked by Unicode version of system function (unless Unicode is disabled with EnableUnicode method). Conversion between ANSI and Unicode is performed internally according to current codepage which can be changed with SetCodePage method. See Unicode Support for more information on Unicode system calls, Unicode methods and Unicode text data.

See Also

File System Operations