CFileDialog dlg(TRUE);
CString mFilePath;
mFilePath = dlg.GetFolderPath();
if (dlg.DoModal() == IDOK)
{
CWnd *pWnd = GetDlgItem(IDC_STATIC_SHOW);
pWnd->SetWindowTextW(m_fileExt);
}
GetFolderPath()
此函数只有在对话框存在的情况下,也就是你没点击打开时可调用,如果此对话框
已经关掉,则不能调用GetFolderPath();
MSDN 提示第2条:
Remarks
The dialog box must have been created with the OFN_EXPLORER style; otherwise, the method will fail with an assertion.
You can call this method only while the dialog box is being displayed. After the dialog box has been closed, this function will no longer work, and the method will fail with an assertion.