Solved

HOWTO set FileDialog to open a specific directory?

Posted on 2001-06-25
4
424 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 42
bobThere java chalenge 45 92
Detect CR LF to each line 12 160
Line meaning 9 86
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…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

772 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