遍历当前目录下所有的.h文件,并将其路径保存到文件中
2013-01-06 22:32
369 查看
本文源程序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
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
相关文章推荐
- Ubuntu 循环遍历当前目录下所有文本文件中的字符
- 在当前目录以及当前目录的所有子目录下查找文件名包含指定字符串的文件,并打印出相对路径
- Linux目录遍历实现 -- 列出当前目录下所有文件
- Python列出当前目录下所有含有指定名称的文件(包括路径)
- Windows和Linux下枚举(遍历)当前文件夹下所有文件完整路径的命令行
- 遍历当前文件目录并且删除所有最近一周没有修改的文件(C/C++)
- #### 批处理命令 获取当前目录下所有文件的路径
- 遍历删除当前目录下所有文件
- 用批处理获取当前目录下所有文件的路径
- 编写一个程序,能在当前目录以及当前目录的所有子目录下查找文件名包含指定字符串的文件,并打印出相对路径。
- 遍历删除当前目录下所有文件
- linux下遍历当前目录下的所有文件和目录
- 编写一个Python程序,能在当前目录以及当前目录的所有子目录下查找文件名包含指定字符串的文件,并打印出相对路径
- 根据路径遍历目录下所有文件File类
- 导出当前目录下所有文件的路径到index.html
- 用PHP遍历当前目录下所有文件
- 获取当前目录所有文件名 并且保存为1个00000.txt的文件文件bat
- 遍历文件目录下所有图片并保存到统一路径
- bat脚本5_获得当前目录下所有文件的相对路径
- sed 列出当前目录下的所有文件形成绝对路径