求大神帮忙啊!在线等

shangyouyiyi 2014-05-01 11:04:51
我用的是vc6.0,现在需要遍历指定文件夹,并读取里面后缀为bmp的图片,保存到数组。图片有很多张。求代码啊
...全文
85 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
schlafenhamster 2014-05-02
  • 打赏
  • 举报
回复
void SearchBmp(LPCTSTR strPath, CStringArray &strFileArray) {// file name in strFileArray CFileFind find; CString strPathFiles = strPath; BOOL bFind; if ( strPathFiles.Right(1) != "\\" ) strPathFiles += "\\"; strPathFiles += "*.bmp"; bFind = find.FindFile( strPathFiles ); while ( bFind ) { bFind = find.FindNextFile(); if ( !find.IsDirectory()) { afxDump << find.GetFilePath() << "\n"; strFileArray.Add(find.GetFilePath()); } } find.Close(); } 调用: CStringArray strFileArray; SearchBmp(".\\res\\", strFileArray);
shangyouyiyi 2014-05-02
  • 打赏
  • 举报
回复
二楼能不能给个全一点的代码啊,新手不会改
shangyouyiyi 2014-05-02
  • 打赏
  • 举报
回复
引用 2 楼 schlafenhamster 的回复:
CFileFind find; CString strPathFiles = strPath; BOOL bFind; CSortStringArray strDirArray; CSortStringArray strFileArray; if ( strPathFiles.Right(1) != "\\" ) strPathFiles += "\\"; strPathFiles += "*.*"; bFind = find.FindFile( strPathFiles ); while ( bFind ) { bFind = find.FindNextFile(); if ( find.IsDirectory() && !find.IsDots() ) { strDirArray.Add( find.GetFilePath() ); } if ( !find.IsDirectory() && m_bFiles ) strFileArray.Add( find.GetFilePath() ); } strDirArray.Sort();
头文件应该添加什么啊
worldy 2014-05-01
  • 打赏
  • 举报
回复
FindFirstFile/FindNextFile 一个一个找
「已注销」 2014-05-01
  • 打赏
  • 举报
回复
vc只有遍历一层目录函数,如果文件夹里还有文件夹,那得自已写遍历函数,
schlafenhamster 2014-05-01
  • 打赏
  • 举报
回复
CFileFind find; CString strPathFiles = strPath; BOOL bFind; CSortStringArray strDirArray; CSortStringArray strFileArray; if ( strPathFiles.Right(1) != "\\" ) strPathFiles += "\\"; strPathFiles += "*.*"; bFind = find.FindFile( strPathFiles ); while ( bFind ) { bFind = find.FindNextFile(); if ( find.IsDirectory() && !find.IsDots() ) { strDirArray.Add( find.GetFilePath() ); } if ( !find.IsDirectory() && m_bFiles ) strFileArray.Add( find.GetFilePath() ); } strDirArray.Sort();

19,469

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧