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;
}