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.