在MFC对话框中选择文件夹收藏

void CBianLiDlg::OnSelectFolder()





















void CBianLiDlg::FileSearch(CString root){ // root 为目录名
CFileFind ff;
CString FilePath;
if (root.Right(1)!="/")
{
root+="/";
}
root+="*.*";
BOOL res=ff.FindFile(root);
while (res)
{
res=ff.FindNextFile();
FilePath=ff.GetFilePath();
if (ff.IsDirectory() && !ff.IsDots())// 找到的是文件夹
{
FileSearch(FilePath);// 递归
}
else if (!ff.IsDirectory() && !ff.IsDots())// 找到的是文件
{
m_ff+=FilePath;
m_ff+=" ";
}
}
}
多文件选择
CFileDialog Dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT); if(Dlg.DoModal()==IDOK)
{
POSITION pos = Dlg.GetStartPosition();
while(pos)
{
CString szFileName = Dlg.GetNextPathName(pos);
AfxMessageBox(szFileName);
}
}