Hi all!! I need to get Folder path but getFolderPath() gives error..Can anybody help me to know WHY?? Code: CFileDialog dlg(TRUE,NULL,NULL,OFN_EXPLORER|OFN_OVERWRITEPROMPT,"JPEG Files (*.*)|*.*||"); INT_PTR ptr = dlg.DoModal(); if(ptr==IDOK) { UpdateData(); CString str = dlg.GetFolderPath(); m_path1.Format("%s",str); UpdateData(FALSE); }
In dlgfile.cpp, within definition of GetFolderPath().. It breaks the execution of program and displays AbortRetryIgnore message..No Error number!!
I am not sure why it should happen but my assumption is the folder is returning but str does not have the necessary buffer to hold the data.
same str giving no such problem with GetPathName( )!! I have passed OFN_EXPLORER as style but even then GetFolderPath() is not returning desired result. Did i make any mistake in code above?? or i have to do it some other way...
The MSDN documentation says that "You can call the GetFolderPath() 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." http://msdn2.microsoft.com/en-us/library/xz5y6xhy(VS.80).aspx Since you are closing the File Open dialog, that is the reason you get this assertion. The code for GetFolderPath() checks this line ASSERT:IsWindow(m_hWnd)). As m_hWnd is NULL in this case, the error occurs. Hope this helps.