2 回答

TA貢獻1804條經(jīng)驗 獲得超2個贊
以獲取D:\test目錄下所有bmp文件路徑為例
void BrowseCurrentAllFile(CString strDir)
{
if (strDir == _T(""))
{
return;
}
else
{
if (strDir.Right(1) != _T("\"))
strDir += L"\";
strDir = strDir + _T("*.bmp");
}
CFileFind finder;
CString strPath;
BOOL bWorking = finder.FindFile(strDir);
while (bWorking)
{
bWorking = finder.FindNextFile();
strPath = finder.GetFilePath();
if (finder.IsDirectory() && !finder.IsDots())
BrowseCurrentAllFile(strPath); //遞歸調(diào)用
else if (!finder.IsDirectory() && !finder.IsDots())
{
//strPath就是所要獲取的文件路徑
//m_List.AddString(strPath);
}
}
}
調(diào)用方式:
BrowseCurrentAllFile(_T("D:\test"));
- 2 回答
- 0 關注
- 1183 瀏覽
添加回答
舉報