• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 284
  • Last Modified:

How to set default directory when using CFileDialog?

hi,

how do I set the default directory (e.g. "c:\temp") when I create the CFileDialog?

I cannot find the method.. pls help..
thanks!

0
Haho
Asked:
Haho
  • 2
1 Solution
 
krispCommented:
Hi,

CFileDialog dlg(....);
dlg.m_ofn.lpstrInitialDir = "c:\temp";

Hope this helps

cheers
 
0
 
HahoAuthor Commented:
shucks! ok. i will try it..
thank you.
0
 
kulinaCommented:
krisp's answer worked for me just fine.
But you have to make sure to do it this way:
CFileDialog dlg;
dlg.m_ofn.lpstrInitialDir = "c:\\temp";

.... in other words to put TWO slashes between directory names, since '\' (slash) is a special character in C\C++.
(Credits to krisp - Thanx krisp);

0
 
HahoAuthor Commented:
thxs
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now