windows 下遍历文件夹

时间:2014-11-26 11:00:06   收藏:0   阅读:233
bubuko.com,布布扣
 1 void reversedir(string srcDir)
 2 {
 3     struct _finddata_t filefind;
 4     string  imgName = srcDir + "\\*.*";
 5     int done=0, handle;  
 6 
 7     if(( handle =_findfirst(imgName.c_str(), &filefind)) == -1)
 8         return;
 9 
10     while(!(done=_findnext(handle, &filefind)))     
11     {         
12         if(!strcmp(filefind.name,"..")){  
13             continue;  
14         }                     
15         if((_A_SUBDIR==filefind.attrib))
16         {             
17             printf("----------%s\n",filefind.name);      
18             cout<< filefind.name << "(dir)" <<endl;     
19         }     
20         else
21         {     
22                 //file
23         }     
24     } 
25     _findclose(handle);
26 }      
View Code

 

评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!