Documentation

FileFindFirst

The function starts the search of files in a directory in accordance with the specified filter.

long  FileFindFirst(
   string   file_filter,           // String - search filter
   string&  returned_filename,     // Name of the file found
   int      common_flag            // Defines the search
   );

Parameters

file_filter

[in]  Search filter. A subdirectory (or sequence of nested subdirectories) relative to the \Files directory, in which files should be searched for, can be specified in the filter.

returned_filename

[out]  The returned parameter, where, in case of success, the name of the first found file is placed.

common_flag

[in] Flag determining the location of the file. If common_flag = FILE_COMMON, then the file is located in a shared folder for all client terminals. Otherwise, the file is located in a local folder.

Return Value

Returns handle of the object searched, which should be used for further sorting of files by the FileFindNext() function, or INVALID_HANDLE when there is no file corresponding to the filter (in the particular case - when the directory is empty). After searching handle must be closed using the FileFindClose() function.

Example:

void OnStart()
  {
   string filename;
//---
   int found=FileFindFirst("*.*",filename);
   if(found!=INVALID_HANDLE)
      Print("FileFindFirst returned",filename);
   else
     {
      Print("Files not found!!! Continue search in Common");
      found=FileFindFirst("*.*",filename,FILE_COMMON);
      if(found!=INVALID_HANDLE)
         Print("FileFindFirst in Common returned",filename);
     }
  }

See also

FileFindNext, FileFindClose