C++??????·??????????????????
???????????? ???????[ 2014/7/14 11:23:27 ] ????????C++ net
??????????ū??????????????????·???μ??????????????????д?????????????
??????????C++????????????к????????????????е??????????÷??????
???????????????????????(??)??io.h?? fstream?? string??
????1??????????·???????????????????????????????·???????????£?
1 void getAllFiles( string path?? vector<string>& files)
2 {
3 //??????
4 long hFile = 0;
5 //??????
6 struct _finddata_t fileinfo; //??????????????????
7 string p; //string????????????????????:assign()???к??????汾
8 if((hFile = _findfirst(p.assign(path).append("\*").c_str()??&fileinfo)) != -1)
9 {
10 do
11 {
12 if((fileinfo.attrib & _A_SUBDIR)) //????????????????????
13 {
14 if(strcmp(fileinfo.name??".") != 0 && strcmp(fileinfo.name??"..") != 0)
15 {
16 files.push_back(p.assign(path).append("\").append(fileinfo.name) );
17 getFilesall( p.assign(path).append("\").append(fileinfo.name)?? files );
18 }
19 }
20 else
21 {
22 files.push_back(p.assign(path).append("\").append(fileinfo.name) );
23 }
24 }while(_findnext(hFile?? &fileinfo) == 0); //?????????????????0??????-1
25 _findclose(hFile);
26 }
27 }
|
?????ú?????????????????????·???????(string????????·??)??????????????????????????洢????(vector????????????)???????????е?????(????????????????"AllFiles.txt"?У???????????)??
1 char * filePath = "E:\YunShi";
2 vector<string> files;
3 char * distAll = "AllFiles.txt";
4 getFilesall(filePath?? files);
5 ofstream ofn(distAll);
6 int size = files.size();
7 ofn<<size<<endl;
8 for (int i = 0;i<size;i++)
9 {
10 ofn<<files[i]<<endl;
11 }
12 ofn.close();
|
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11