CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2011
    Posts
    1

    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.

  2. #2
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    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...

  3. #3
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    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 '|'.
    Best regards,
    Igor

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured