C++下 遍历文件夹
来源:互联网 发布:淘宝四件套好评语50字 编辑:程序博客网 时间:2024/05/16 19:08
用CFileFind 实现
CFileFind ff;
CString l_strFilePath;
CString l_strFileName;
CString l_strFileExt;
CString l_strFileTitle;
CString l_strFileUrl;
CString l_strFileRoot;
DWORD l_dwLength;
CString l_strResult;
int l_nPoint;
int l_nLength;
CString m_strResult = "";
CString m_strDir = "f://hoho";
CString l_strDir = m_strDir;
if(l_strDir.Right(1) != "//")
l_strDir += "//";
l_strDir += "*.*";
BOOL res = ff.FindFile(l_strDir);
while(res)
{
res = ff.FindNextFile();
// 不遍历子目录
if(!ff.IsDirectory() && !ff.IsDots())
{
l_strFilePath = ff.GetFilePath();
l_strFileName = ff.GetFileName();
l_nPoint = l_strFileName.ReverseFind('.'); // 因为文件名中可能出现多个'.'所以用ReverseFind而不用Find?
l_nLength = l_strFileName.GetLength();
l_strFileExt = l_strFileName.Right(l_nLength - l_nPoint - 1);
l_strFileTitle = ff.GetFileTitle();
l_strFileUrl = ff.GetFileURL();
l_strFileRoot = ff.GetRoot();
l_dwLength = ff.GetLength();
l_strResult.Format("Filepath: %s/r/nFileName: %s/r/nFileExe: %s/r/nnFileTitle: %s/r/nFileUrl: %s/r/nFileRoot: %s/r/nFileLength: %d/r/n/r/n", l_strFilePath, l_strFileName, l_strFileExt, l_strFileTitle, l_strFileUrl, l_strFileRoot, l_dwLength);
m_strResult += l_strResult;
}
}
ff.Close();
- linux下C遍历文件夹
- Linux c 遍历文件夹下的文件名
- c遍历文件夹
- C/C++遍历文件夹
- c 遍历文件夹
- C/C++ 遍历文件夹
- C#--遍历文件夹实例
- C/C++遍历文件夹
- c/c++遍历文件夹
- C++下遍历文件夹
- C++下 遍历文件夹
- linux 下遍历文件夹
- C++下遍历文件夹
- C++下遍历文件夹
- C++下遍历文件夹
- C++下遍历文件夹
- WIN下遍历文件夹
- C++下遍历文件夹
- mysql下普通索引和唯一索引的效率对比
- XmlSerializer 对象的Xml序列化和反序列化
- Eclipse 安装 svn插件 和 egit 插件
- 国家码
- 20 个设计师需要了解的免费 Mac 软件
- C++下 遍历文件夹
- Ubuntu 通过PPA源安装 Cairo-Dock
- java @override 报错处理
- 红帽混合云建设
- Android四大组件介绍
- 第14周-项目2-抽象类Shape
- 瑞萨单片机程序1
- 巧用甲骨文技术:大幅跃进企业SAP/ERP的服务能力
- 来自极客标签10款最新设计素材-系列八