windows 下遍历文件夹

 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

 

posted on 2014-11-26 09:58  VincentEcho  阅读(208)  评论(0编辑  收藏  举报

导航