枚举文件目录及该目录下的子目录

void EnumFolders()

{

          WIN32_FIND_DATA fd;

          HANDLE hFind=::FindFirstFile(_T("*.*"),&fd);

 

          if(hFind!=INVALID_HANDLE_VALUE)

           {

                  do{

                           if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)

                                 {

                                      CString name=fd.cFileName;

                                      if(name!=_T(".")&&name!=_T(".."))

                                             {

                                                    ::SetCurrentDirectory(fd.cFileName);

                                                    EnumFolders();

                                                    ::SetCurrentDirectory(_T(".."));

                                              }

                                   }

                             }while(::FindNextFile(hFind,&fd));

                        ::FindClose(hFind);

            }

}

你可能感兴趣的:(枚举文件目录及该目录下的子目录)