26.boost文件库

 1 #define _CRT_SECURE_NO_WARNINGS
 2 #include <boost/filesystem/operations.hpp>
 3 #include <boost/filesystem.hpp>
 4 #include <iostream>
 5 using namespace std;
 6 using namespace boost;
 7 
 8 
 9 void main()
10 {
11     boost::filesystem::directory_iterator begin("C:\\");
12     boost::filesystem::directory_iterator end;
13 
14     for (; begin != end; begin++)
15     {
16         //文件状态
17         boost::filesystem::file_status fs = begin->status();
18 
19         switch (fs.type())
20         {
21         case boost::filesystem::regular_file:
22             cout << "标准文件" << endl;
23             break;
24         case boost::filesystem::symlink_file:
25             cout << "操作系统文件" << endl;
26             break;
27         case boost::filesystem::directory_file:
28             cout << "文件夹" << endl;
29             break;
30         default:
31             break;
32         }
33         cout << begin->path() << endl;
34     }
35     cin.get();
36 }

 

posted @ 2018-04-02 10:49  喵小喵~  阅读(165)  评论(0编辑  收藏  举报