Solved

HOWTO set FileDialog to open a specific directory?

Posted on 2001-06-25
4
411 Views
Last Modified: 2013-11-20
Hello!

I have a SDI Document/View MFC app and I would like that the Open  FileDialog and Save/Save as... FileDialog open on a default directory.

Thanks a lot!
0
Comment
Question by:jussara
  • 2
4 Comments
 
LVL 12

Expert Comment

by:migel
ID: 6224848
Hi!
try this:

add command handler for ID_FILE_OPEN  to the your APP class:

void CMyApp::OnFileOpen()
{
     // TODO: Add your command handler code here
     CString newName = _T("C:"\*.*");
     if (!DoPromptFileName(newName, AFX_IDS_OPENFILE,
          OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, TRUE, NULL))
          return; // open cancelled
     
     OpenDocumentFile(newName);
}

0
 
LVL 12

Expert Comment

by:migel
ID: 6224851
of course use your path instead
C:\*.*
0
 
LVL 2

Accepted Solution

by:
Chandra V earned 50 total points
ID: 6226408
Assuming

CFileDialog myDlg;//Use your own

Use

myDlg.m_ofn.lpstrInitialDir="c:\\";// Use your Own

to set your initial directory.
0
 

Expert Comment

by:leowlf
ID: 6261081
Or

_chdir( "c:\\" );
CFileDialog myDlg(1);
myDlg.DoModal();
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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

947 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

19 Experts available now in Live!

Get 1:1 Help Now