需要复制的文件有一百多个,每次都会有一个文件复制不了,不知道原因在哪里?
代码如下:
CFileFind finder;
CString strFilePathName = _T(pView->c3dpath + "\\" + "*.*");
BOOL bWorking = finder.FindFile(strFilePathName);

CString fileName;
while (bWorking)
{
    fileName = finder.GetFileName();
    bWorking = finder.FindNextFile();
// AfxMessageBox(fileName);
    CopyFile(pView->c3dpath + "\\" + fileName,_T(examPath + "\\" + fileName),FALSE);
}
finder.Close();

解决方案 »

  1.   

    CFileFind finder;   // build a string with wildcards
       CString strWildcard(pstr);
       strWildcard += _T("\\*.*");   // start working for files
       BOOL bWorking = finder.FindFile(strWildcard);   while (bWorking)
       {
          bWorking = finder.FindNextFile();      // skip . and .. files; otherwise, we'd
          // recur infinitely!      if (finder.IsDots())
             continue;      // if it's a directory, recursively search it      if (finder.IsDirectory())
          {
             CString str = finder.GetFilePath();
             TRACE(_T("%s\n"), (LPCTSTR)str);
             //Recurse(str);
          }
          else
          {
              fileName = finder.GetFileName();
              CopyFile(pView->c3dpath + "\\" + fileName,_T(examPath + "\\" + fileName),FALSE);      }
       }   finder.Close();
      

  2.   

    奇怪了?
    一开始写的是:CString strFilePathName = _T(pView->c3dpath + "\\" + "*.*");
    后来改成:CString strFilePathName = _T(pView->c3dpath + "\\" + "*.*");
    就这样莫名其妙的好了..