CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: CFileDialog

  1. #1
    Join Date
    Aug 2008
    Posts
    373

    CFileDialog

    Hi All

    i am try to save file through CFileDialog.I search and read from google then use this code.
    Code:
    CString filter="Excel Files(*.xls;*.xlsx)|*.xls;*.xlsx|Text Files(*.txt)|*.txt|CSV Files(*.csv)|*.csv||";
    
    	CFileDialog fileDlg(FALSE, NULL, NULL, OFN_PATHMUSTEXIST|OFN_OVERWRITEPROMPT,filter);
    	if(fileDlg.DoModal()==IDCANCEL)
    	{
    		return;
    	}
    	CString filepath = fileDlg.GetPathName ();
    It's not working proper.When i select Text Files option from drop down from CFileDialog then Blank show in CFileDialog.

    Really i don't know why this this thing happen in my application please help me

  2. #2
    Join Date
    May 2006
    Location
    Dresden, Germany
    Posts
    458

    Re: CFileDialog

    Hi,

    I copied your code into my test app and it worked fine.

    What do you mean by saying "then Blank show in CFileDialog"?
    If I select "Text files" in the drop down of the CFileDialog this dialog will only show text files. So if there aren't any, then the file list could be empty of course.

    With regards
    Programartist

  3. #3
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: CFileDialog

    So when you select "text files" for the file type, you don't see any file in the dialog? Does the current folder has any .txt files? Did you try another folder with .txt files?
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  4. #4
    Join Date
    Aug 2008
    Posts
    373

    Re: CFileDialog

    Quote Originally Posted by ProgramArtist View Post
    Hi,

    I copied your code into my test app and it worked fine.

    What do you mean by saying "then Blank show in CFileDialog"?
    If I select "Text files" in the drop down of the CFileDialog this dialog will only show text files. So if there aren't any, then the file list could be empty of course.

    With regards
    Programartist
    No there is so many text file exist.

  5. #5
    Join Date
    Aug 2008
    Posts
    373

    Re: CFileDialog

    Quote Originally Posted by cilu View Post
    So when you select "text files" for the file type, you don't see any file in the dialog? Does the current folder has any .txt files? Did you try another folder with .txt files?
    There text file exist.When i click on Desktop Icon then file is showing.

    But when i go through select file type then nothing showing in CFileDialog.
    Please help me

  6. #6
    Join Date
    May 2006
    Location
    Dresden, Germany
    Posts
    458

    Re: CFileDialog

    Hi,

    there's nothing wrong with the code you've posted.

    Do the files have the right extension ("*.txt")?
    Are they shown if you try to show all files ("*.*")?

    With regards
    Programartist

  7. #7
    Join Date
    Aug 2008
    Posts
    373

    Re: CFileDialog

    Quote Originally Posted by ProgramArtist View Post
    Hi,

    there's nothing wrong with the code you've posted.

    Do the files have the right extension ("*.txt")?
    Are they shown if you try to show all files ("*.*")?

    With regards
    Programartist
    i had try all possible extension but result is same blank.

    See when i select file option from CFileDialog then nothing show even My Document ,My Computer
    Please help me

  8. #8
    Join Date
    May 2006
    Location
    Dresden, Germany
    Posts
    458

    Re: CFileDialog

    Dear Msm,

    I've tested exactly the code you've posted. It did work. Selecting "Text files (*.txt)" I see all folders (incl. "My Documents" which is called "Eigene Dokumente" since I'm using a German Windows) and all text files.

    Can you explain in more details what exactly you're doing, what you're expecting and what are the results?

    I'm using a Win XP SP3 (German).

    With regards
    Programartist

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