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!

LVL 1
HahoAsked:
Who is Participating?
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.