又很多文件都是放在同一文件夹中的,现在想写代码打开一个处理完,再打开下一个,怎么办?

解决方案 »

  1.   

    用 CFileFind 枚举指定文件夹下的所有文件: CFileFind finder;
    // start working for files
    BOOL bWorking = finder.FindFile(strWildcard);
    while (bWorking)
    {
    bWorking = finder.FindNextFile(); if (finder.IsDots())
    continue;
    if (!finder.IsDirectory())
    {
    CString str = finder.GetFilePath();
    MessageBox(str);
    }
    } finder.Close();
      

  2.   

    BOOL bWorking = finder.FindFile(pathName);  成功了 返回了1
    为什么  bWorking = finder.FindNextFile();     失败了,返回了0呢?
      

  3.   

    zero if the file found is the last one in the directory or if an error occurred. To get extended error information, call the Win32 function GetLastError. If the file found is the last file in the directory, or if no matching files can be found, the GetLastError function returns ERROR_NO_MORE_FILES. 
      

  4.   

    这个是MSDN上的原话吧,我的问题找到了,原来开始打开的那个应该是*.*的文件组,不是单个文件夹,或者第一个文件。不过还是谢谢你们关注这个这题!