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.