// 获取当前路径下的所有文件(子文件)
void BrowseCurrentDir(CString strDir) {
CFileFind finder;
CString strPath;
CString strName;
if (strDir.Right(1) != _T("\\")) {
strDir += _T("\\");
}
strDir += _T("*.*");
BOOL bWorking = finder.FindFile(strDir);
while (bWorking) {
bWorking = finder.FindNextFile();
if (finder.IsDots()) {
continue;
}
if (finder.IsDirectory()) {
strPath = finder.GetFilePath();
//strName = finder.GetFileName();
ODS(strPath);
BrowseCurrentDir(strPath); //递归调用
} else {
strPath = finder.GetFilePath();
strName = finder.GetFileName();
ODS(strPath);
ODS(_T("fileName: ") + strName);
TCHAR fileName[MAX_PATH];
wcscpy_s(fileName, strName);
TCHAR *p = wcsrchr(fileName, '.');
if (p != NULL) {
ODS(_T("拓展名为: "), p);
if (wcscmp(_T(".lnk"), p) == 0) {
ODS(_T("相等"));
}
} else {
ODS(_T("无拓展名!"));
}
}
}
finder.Close();
}
获取当前路径下的所有文件(子文件)
最新推荐文章于 2023-12-30 00:04:10 发布
