比如:
char szFilters[] = "All files (*.*)|*.*||";
CFileDialog FileDialog(true, ".txt", "", OFN_EXPLORER,
szFilters, this); //显示对话框
if(FileDialog.DoModal() == IDOK)
{
strDir = FileDialog.GetPathName();
UpdateData(FALSE);
}
我的意思是只选中目录如c:\的就可以返回
而不需要选中*.txt什么之类的因为我的目的是搜索目录下的文件所以只需要目录名不需要具体的文件.
char szFilters[] = "All files (*.*)|*.*||";
CFileDialog FileDialog(true, ".txt", "", OFN_EXPLORER,
szFilters, this); //显示对话框
if(FileDialog.DoModal() == IDOK)
{
strDir = FileDialog.GetPathName();
UpdateData(FALSE);
}
我的意思是只选中目录如c:\的就可以返回
而不需要选中*.txt什么之类的因为我的目的是搜索目录下的文件所以只需要目录名不需要具体的文件.
BROWSEINFO bi; LPITEMIDLIST pidl;
bi.hwndOwner = this->GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = pszBuffer;
CString str;
str.LoadString(IDS_RECEIVEFILEPATH);
bi.lpszTitle = str;
bi.ulFlags = BIF_RETURNONLYFSDIRS ;
bi.lpfn = NULL;
bi.lParam = 0;
pidl = SHBrowseForFolder(&bi);
SHGetPathFromIDList(pidl, pszBuffer);
pszBuffer是返回的目录