http://bbs.csdn.net/topics/390368005
// 遍历给定目录下所有子目录,查找*.txt,放入CStringArray中
void
CTestMADlg::getFolderDayFile(CString pathStr, CStringArray& arrStrFile)
{
CString myDataPath,fdPath;
myDataPath=pathStr +
"\\*.*"
;
CString strTmp;
CFileFind find;
BOOL
bf = find.FindFile(myDataPath);
while
(bf)
{
bf = find.FindNextFile();
if
(!find.IsDots())
{
fdPath=find.GetFilePath();
if
(find.IsDirectory())
{
//如果是文件夹,递归,继续往下找
getFolderDayFile(fdPath, arrStrFile);
}
else
{
//如果是文件,判断是否是*.txt
strTmp=fdPath.Right(4);
strTmp.MakeLower();
if
( strTmp==
".txt"
)
arrStrFile.Add(fdPath);
}
}
}
find.Close();
}