跳至内容

FileFindNext

FileFindNext

此函数继续由FileFindFirst()开始搜索。

bool  FileFindNext(
   long      search_handle,         // Search handle
   string&   returned_filename      // Name of the file or subdirectory found
   );

参数

search_handle

[in] 通过FileFindFirst()获取的搜索句柄。

returned_filename

[out] 找到的下一个文件或子目录的名称。仅返回文件名(包括扩展名),无论是否在搜索过滤器中指定,目录和子目录均不会包含在内。

返回值

如果成功则返回true,否则返回false。

示例:

//--- display the window of input parameters when launching the script
#property script_show_inputs
//--- filter
input string InpFilter="*";
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   string file_name;
   int    i=1;
//--- receive search handle in local folder's root
   long search_handle=FileFindFirst(InpFilter,file_name);
//--- check if FileFindFirst() function executed successfully
   if(search_handle!=INVALID_HANDLE)
     {
      //--- check if the passed strings are file or directory names in the loop
      do
        {
         ResetLastError();
         //--- if this is a file, the function will return true, if it is a directory, the function will generate error ERR_FILE_IS_DIRECTORY
         FileIsExist(file_name);
         PrintFormat("%d : %s name = %s",i,GetLastError()==ERR_FILE_IS_DIRECTORY ? "Directory" : "File",file_name);
         i++;
        }
      while(FileFindNext(search_handle,file_name));
      //--- close search handle
      FileFindClose(search_handle);
     }
   else
      Print("Files not found!");
  }

参见

FileFindFirst(), FileFindClose()

最后更新于