struct ThreadParameter { CString file_path_name; }; //注意這裏調用時候,路徑要加上\\*.*" 或者 /*.*
vector<ThreadParameter> vec_filepaths;
//CString strDirPath = _T("E:\\google-cpp-style\\TestEn_DecryptDLL_v1.0\\TestEn_DecryptDLL\\data\\multithread\\plain\\*.*");
CString strDirPath = _T("data/multithread/plain/*.*");
vec_filepaths.clear();
GetFiles(strDirPath, vec_filepaths);
for (int i = 0; i < vec_filepaths.size(); ++i)
{
OutputDebugString(vec_filepaths[i].file_path_name);
OutputDebugString(_T("\n"));
}
BOOL CTestEn_DecryptDLLDlg::GetFiles(CString strPath, vector<ThreadParameter> &vec_filepaths) { CFileFind finder; BOOL bWorking = finder.FindFile(strPath); while (bWorking) { //若是還有文件存在就繼續執行 bWorking = finder.FindNextFile(); if (finder.IsDots()) //. 或者.. { bWorking = finder.FindNextFile(); continue; } //通常文件及文件夾 BOOL bisDir = finder.IsDirectory(); if (bisDir) { //文件夾 CString repath = finder.GetFilePath(); GetFiles(strPath, vec_filepaths); } else { //文件 ThreadParameter tp; tp.file_path_name = finder.GetFilePath(); vec_filepaths.push_back(tp); } } finder.Close(); return 1; }