Solved

CFileDialog returning invalid file name after file selections from the root

Posted on 2000-05-17
6
330 Views
Last Modified: 2013-11-20
For some reason file selection goes great until I select files from the root.  The first time I select files from the root everything works as expected.  The next time I open the CFileDialog the box and DoModal for the class returns FNERR_INVALIDFILENAME.
This is the constructor:
m_pFileDialog=new CFileDialog( TRUE, NULL, NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT|OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST, "All Files (*.*)|*.*||");

m_pFileDialog->m_ofn.lpstrTitle="Select Files for SoftPack";

At present this is the only action taken in response to a button click.

void CSoftwareDispatcherDlg::OnBnSoftpackAddfiles()
{
  POSITION pos;
  CString sPathFileName;
  int iret;
  DWORD dwDlgExtError;

  iret=m_pFileDialog->DoModal();
  //see cderr.h for meaning of extended errors returned by   CommDlgExtendedError();
  if(iret==IDCANCEL)
    dwDlgExtError=CommDlgExtendedError();
  pos=m_pFileDialog->GetStartPosition();
  while(pos)
  {
    sPathFileName=m_pFileDialog->GetNextPathName(pos);
    m_lbSoftPackFiles.AddString(sPathFileName);
  }
}
0
Comment
Question by:graber
  • 3
  • 3
6 Comments
 
LVL 4

Expert Comment

by:captainkirk
Comment Utility
I can't get it to fail - seems to work fine. BTW, DoModal can only return IDOK or IDCANCEL... you must be calling GetOpenFileName() or GetSaveFileName() to get FNERR_INVALIDFILENAME returned...
0
 
LVL 2

Author Comment

by:graber
Comment Utility
CommDlgExtendedError()  will give you the same thing.  Use it after the doModal returns IDCANCEL.
If you want Kap I will send you the source code.  You will need to comment out the Database stuff.  It uses ODBC communication level.  But the file stuff should work the same.  I have made some changes thought.  Originally the CFileDialog point was "newed" in the CDialog class constructor and deleted in destructor.
0
 
LVL 4

Expert Comment

by:captainkirk
Comment Utility
Yeah, if you could zip up the project, the email is khutchinson@tvgnetwork.com

I'll take a look and see what's going on...

0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 2

Author Comment

by:graber
Comment Utility
Adjusted points from 200 to 300
0
 
LVL 2

Author Comment

by:graber
Comment Utility
Yeah I would give ya the points for just a code review.  I will zip and send.  Thanks Kap.
Gregg
0
 
LVL 4

Accepted Solution

by:
captainkirk earned 300 total points
Comment Utility
no problemo...
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now