首页 > 代码库 > windows 下遍历文件夹

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         else21         {     22                 //file23         }     24     } 25     _findclose(handle);26 }      
View Code

 

windows 下遍历文件夹