Solved

CFileDialog returning invalid file name after file selections from the root

Posted on 2000-05-17
6
333 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
ID: 2817875
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
ID: 2818205
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
ID: 2818233
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Author Comment

by:graber
ID: 2818250
Adjusted points from 200 to 300
0
 
LVL 2

Author Comment

by:graber
ID: 2818251
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
ID: 2818261
no problemo...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Pressing cancel button with C# UI Automation 3 51
deburging in oracle form 12 88
VBA "SendKeys" Syntax for Multiple Keystrokes 7 103
unix example issues 18 75
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 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

11 Experts available now in Live!

Get 1:1 Help Now