Error while calling CFileDialog
Hi.
I have used CFileDialog to get the path of the file what users select.
When I programmed in Windows XP and Visual Studio 6.0, 2008
I didn't have any problem.
However, I changed my environment to Windows 7 & Visual Studio 2010,
since then, sometimes error is occurred.
It is not always, about 1 or 2 times per 5?
My code is here.
CString csTemp;
TCHAR szFilter[] = L"CSV Files(*.csv)|*.csv|";
CFileDialog fileDlg(TRUE, NULL, NULL, OFN_NOVALIDATE, szFilter);
if(IDOK == fileDlg.DoModal())
csTemp=fileDlg.GetPathName();
else
{
MessageBox(_T("File Open Fail"));
return;
}
When DoModal function is called. everything is stop.
cant stop debugging, no task manager, no ctrl+alt+del, just only reboot.
I changed the option "OFN_NOVALIDATE" to solve this problem...
unfortunately, it doesn't work.
if u have any good idea. plz help me.
Re: Error while calling CFileDialog
Code:
TCHAR szFilter[] = L"CSV Files(*.csv)|*.csv|";
Needs an extra | at the end
Code:
TCHAR szFilter[] = L"CSV Files(*.csv)|*.csv||";
Don't know if that is the problem btw...
Re: Error while calling CFileDialog
Quote:
Originally Posted by Skizmo
Code:
TCHAR szFilter[] = L"CSV Files(*.csv)|*.csv|";
Needs an extra | at the end
Not sure if this needed. The vertical bar is replaced by '\0'. Along with the terminating '\0' they both make "\0\0" which is a terminator for the multi-string buffer. Everything seems fine even with single '|'.