文件的遍历

//从张同学那边弄过来的,谢谢哈!
void ListFile()
{
    HANDLE hSearch;
    WIN32_FIND_DATA data;
    hSearch=FindFirstFile("*",&data);
    do
    {
        if(data.dwFileAttributes==FILE_ATTRIBUTE_DIRECTORY&&strcmp(data.cFileName,".")&&strcmp(data.cFileName,".."))
        {
            SetCurrentDirectory(data.cFileName);

			//cout<<data.cFileName<<"    ";
            ListFile();
            SetCurrentDirectory("..");
        }
        else
           if(strcmp(data.cFileName,".")&&strcmp(data.cFileName,".."))
           {
               //cout<<data.cFileName<<"    ";
               file(data.cFileName);
               ++total;
		   }
    }while(FindNextFile(hSearch,&data));
    FindClose(hSearch);
}

;

Popular Programs