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()

//

不要指差虚忘记关闭

若满意请及时采纳,谢谢


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

原文地址: https://outofmemory.cn/tougao/12127346.html

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

发表评论

登录后才能评论

评论列表(0条)

保存