C++遍历文件夹

阅读更多

C++遍历文件夹的代码如下:

                    

  #include   
  #include   
  #include  
  using namespace std; 

  void   visit(string path,int layer)   
  {   
          struct _finddata_t   filefind;   
          string  curr=path+"\\*.*";   
          int   done=0,i,handle;   
          if((handle=_findfirst(curr.c_str(),&filefind))==-1)return;     
          while(!(done=_findnext(handle,&filefind)))   
          {   	
              printf("%s\n",filefind.name);    
              if(!strcmp(filefind.name,"..")){
		 continue;
              }
              for(i=0;i>path;
          visit(path,1);   
          system("PAUSE");   
          return   0;     
  }   
  

 

你可能感兴趣的:(C,C++,C#)