免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2181 | 回复: 4
打印 上一主题 下一主题

MINGW下,如何出现获得某个指定目录下的文件列表? [复制链接]

论坛徽章:
1
IT运维版块每日发帖之星
日期:2016-03-08 06:20:00
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-05-05 14:11 |只看该作者 |倒序浏览
minGW好象不支持findfirst等函数?

论坛徽章:
24
狮子座
日期:2013-12-31 10:48:0015-16赛季CBA联赛之吉林
日期:2016-04-18 14:43:1015-16赛季CBA联赛之北控
日期:2016-05-18 15:01:4415-16赛季CBA联赛之上海
日期:2016-06-22 18:00:1315-16赛季CBA联赛之八一
日期:2016-06-25 11:02:2215-16赛季CBA联赛之佛山
日期:2016-08-17 22:48:2615-16赛季CBA联赛之福建
日期:2016-12-27 22:39:272016科比退役纪念章
日期:2017-02-08 23:49:4315-16赛季CBA联赛之八一
日期:2017-02-16 01:05:3415-16赛季CBA联赛之山东
日期:2017-02-22 15:34:5615-16赛季CBA联赛之上海
日期:2017-11-25 16:17:5015-16赛季CBA联赛之四川
日期:2016-01-17 18:38:37
2 [报告]
发表于 2010-05-05 14:29 |只看该作者
minGW好象不支持findfirst等函数?
f310 发表于 2010-05-05 14:11



    必要时可以在 mingw 中用 win32api。

论坛徽章:
5
狮子座
日期:2013-08-20 10:12:24午马
日期:2013-11-23 18:04:102015年辞旧岁徽章
日期:2015-03-03 16:54:152015亚冠之德黑兰石油
日期:2015-06-29 18:11:1115-16赛季CBA联赛之新疆
日期:2024-02-21 10:00:53
3 [报告]
发表于 2010-05-05 15:33 |只看该作者
readdir有么?

论坛徽章:
1
IT运维版块每日发帖之星
日期:2016-03-08 06:20:00
4 [报告]
发表于 2010-05-05 21:07 |只看该作者
必要时可以在 mingw 中用 win32api。
zhujiang73 发表于 2010-05-05 14:29



    win32API实在是有点麻烦!

论坛徽章:
0
5 [报告]
发表于 2010-05-05 22:50 |只看该作者
如果允许使用C++的话

  1. #include <string>
  2. #include <boost/algorithm/string.hpp>
  3. #include <boost/filesystem/operations.hpp>
  4. #include <boost/filesystem/path.hpp>
  5. #include <boost/filesystem.hpp>
  6. using namespace std;
  7. using namespace boost::filesystem;
  8. using namespace boost::algorithm;
  9. ...
  10. directory_iterator end_iter;
  11. for ( directory_iterator dir_itr( filepath1 ); dir_itr != end_iter; ++dir_itr )
  12. {
  13.         if( is_regular_file( dir_itr->status() ) )
  14.         {
  15.                 string ext = dir_itr->path().extension();
  16.                 to_upper(ext);
  17.                 if( ext == ".TXT" )
  18.                 {
  19.                         cout << dir_itr->path() << endl;
  20.                                         succ=true;
  21.                 }
  22.         }       
  23. }

复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP