MFC C++ 遍歷文件夾,子文件夾所有文件

void GetFilePath(vector<CString>& vFilePathList,CString strDir) 
{ 
    CFileFind finder; 
    BOOL isNotEmpty = finder.FindFile(strDir+_T("*.*"));//總文件夾,開始遍歷 
    while(isNotEmpty) 
    { 
        isNotEmpty = finder.FindNextFile();//查找文件 
        CString filename = finder.GetFilePath();//獲取文件的路徑,可能是文件夾,可能是文件 
        if (!(finder.IsDirectory())) 
        { 
            //如果是文件則加入文件列表 
            vFilePathList.push_back(filename);//將一個文件路徑加入容器 
        } 
        else 
        { 
            //遞歸遍歷用戶文件夾,跳過非用戶文件夾 
            if(!(finder.IsDots()||finder.IsHidden()||finder.IsSystem()||finder.IsTemporary()||finder.IsReadOnly())) 
            { 
                GetFilePath(vFilePathList,filename+_T("/")); 
            } 
        } 
    } 
}

https://blog.csdn.net/shufac/article/details/50728148

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章