本文源程序vs2008实现 免积分下载地址: http://download.csdn.net/detail/moonshine99/4967281
void CFindAllFilesInDirDlg::OnBnClickedOk()
{CString strCurrentPath;
GetModuleFileName(AfxGetInstanceHandle(),strCurrentPath.GetBufferSetLength(MAX_PATH+1),MAX_PATH);
int iPos = strCurrentPath.ReverseFind('\\');
strCurrentPath = strCurrentPath.Left(iPos);
CFile file;
file.Open(L"h.txt",CFile::modeCreate | CFile::modeWrite);
Recurse(file, strCurrentPath);
file.Close();
CString strPath("D:");
}
void CFindAllFilesInDirDlg::Recurse(CFile &file, LPCTSTR pstr)
{
CFileFind finder;
CString strWildcard(pstr);
strWildcard += _T("\\*.*");
BOOL bWorking = finder.FindFile(strWildcard);
while(bWorking)
{bWorking=finder.FindNextFile();
CString temp=finder.GetFilePath();
if (finder.IsDots())
continue;
if(finder.IsDirectory())
{
CString str = finder.GetFilePath();
Recurse(file,str);
}
if(temp.Right(2) == ".h")
{
temp += L"\r\n";
file.Write(temp,temp.GetLength()*sizeof(TCHAR));
}
}
finder.Close();
}
本文源程序vs2008实现 免积分下载地址: http://download.csdn.net/detail/moonshine99/4967281