Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

HOWTO set FileDialog to open a specific directory?

Posted on 2001-06-25
4
Medium Priority
?
452 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 100 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

927 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