示例代码如下:
CFileFind fFinder;
BOOL bFind = fFinder.FindFile(TEXT("D:/*.*"));
while (bFind)
{
bFind = fFinder.FindNextFile();
//当前文件夹及上层文件夹(名称分别为.和..)-----------------
if (fFinder.IsDots())
{
continue;
}
//子文件夹---------------------------------------------
if(fFinder.IsDirectory())
{
CString cstrDirName = fFinder.GetFileName(); //directory name
CString cstrDirPath = fFinder.GetFilePath(); //directory path
continue;
}
//文件-------------------------------------------------
CString cstrFileName = fFinder.GetFileName(); //file name
CString cstrFilePath = fFinder.GetFilePath(); //file path
}
fFinder.Close();