MFC 打开文件夹和文件
我们都知道MFC打开文件的CFileDialog类。
CString m_strFilePathName; CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,_T("All Files(*.txt)|*.txt|所有文件(*.*)|*.*|"),NULL); if (dlg.DoModal()) { m_strFilePathName = dlg.GetPathName(); }
char szDir[MAX_PATH]; BROWSEINFO bi; ITEMIDLIST *pidl; bi.hwndOwner = this->m_hWnd; bi.pidlRoot = NULL; bi.pszDisplayName = szDir; bi.lpszTitle = "请选择目录"; bi.ulFlags = BIF_STATUSTEXT | BIF_USENEWUI | BIF_RETURNONLYFSDIRS; bi.lpfn = NULL; bi.lParam = 0; bi.iImage = 0; pidl = SHBrowseForFolder(&bi); if(pidl == NULL) return; if(!SHGetPathFromIDList(pidl, szDir))