Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   GetFolderPath() error!! (http://www.go4expert.com/forums/getfolderpath-error-t5996/)

KaimTazz 23Aug2007 17:38

GetFolderPath() error!!
 
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);
        }


shabbir 23Aug2007 17:58

Re: GetFolderPath() error!!
 
What error does it gives?

KaimTazz 23Aug2007 18:08

Re: GetFolderPath() error!!
 
In dlgfile.cpp, within definition of GetFolderPath()..

It breaks the execution of program and displays AbortRetryIgnore message..No Error number!!

shabbir 23Aug2007 19:01

Re: GetFolderPath() error!!
 
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.

KaimTazz 24Aug2007 11:10

Re: GetFolderPath() error!!
 
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...

shabbir 24Aug2007 11:32

Re: GetFolderPath() error!!
 
Dialog type should be Folder Dialog and not of the type FileDialog but I am not sure of that.

rups 30Aug2007 23:58

Re: GetFolderPath() error!!
 
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.


All times are GMT +5.5. The time now is 15:19.