现在的位置: 首页 > 综合 > 正文

枚举某目录下所有文件

2018年05月01日 ⁄ 综合 ⁄ 共 675字 ⁄ 字号 评论关闭

void CopyDmp::EnumLogFile(const std::wstring & cstrPath, std::vector<std::wstring> & vecFiles)
{
 HANDLE hFindFile = INVALID_HANDLE_VALUE;
 WIN32_FIND_DATA struFindFileData;
 hFindFile=FindFirstFile( (cstrPath + L"\\*.dmp").c_str(), &struFindFileData );
 if (hFindFile == INVALID_HANDLE_VALUE )
 {
  return ;
 }
 do
 {
  
  if ( !_tcscmp( struFindFileData.cFileName, _T( "." ) ) || !_tcscmp( struFindFileData.cFileName, _T( ".." ) ))
  {
   continue;
  }
  
  if ( 0 != (struFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
  {
   ;
  }
  else
  {
   if(wcsstr(struFindFileData.cFileName, L".dmp"))
   {
    vecFiles.push_back(cstrPath + L"\\" + struFindFileData.cFileName) ;
   }   
  }
 } while ( FindNextFile( hFindFile, &struFindFileData ) );
}

抱歉!评论已关闭.