mfc怎样获取一个文件夹下所有的文件

mfc怎样获取一个文件夹下所有的文件,第1张

void CXXXDlg::SearchFiles(CString strMusicFolder)

{

    CFileFind ff

    

    strMusicFolder += _T("\\")

    

 局扒喊   strMusicFolder += _T("桐野*.*")

    BOOL res = ff.FindFile(strMusicFolder)

    此世while (res)

    {

        res = ff.FindNextFile()

        if (!ff.IsDirectory() && !ff.IsDots())

        {

            afxMessageBox(ff.GetFilePath())

        }

    }

    ff.Close()

}

用下面的程序段可以实现你要求的功能

CFileFind ff

CString strDir= "d:\\Program Files\\*.*"

BOOL res = ff.FindFile(strDir)

while(res)

{

res = ff.FindNextFile

if(ff.IsDirectory() &&(!ff.IsDots()))()//遍历子目培做敏录,剔除".0”和".."两配枝个

{

CString strFile = ff.GetFileName()

// 在这里写需要的代码

}

}

ff.Close()// 不要忘记胡顷关闭

若满意请及时采纳,谢谢


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/12224476.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-22
下一篇 2023-05-22

发表评论

登录后才能评论

评论列表(0条)

保存