views:

441

answers:

3

Hi,

I know it is possible to set the current folder of the OpenFolderDialog to a special folder, like "Program Files" or Desktop?

But where do I find this?

+3  A: 

Look at the System.Environment class, e.g:

string programFiles = System.Environment.GetFolderPath(
     System.Environment.SpecialFolder.ProgramFiles);

Update:

I'm not sure if this is part of the question, but to open the folder selection dialog, you then use this code:

using System.Windows.Forms;

//...

FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.SelectedPath = programFiles;
dialog.ShowDialog();

string selectedPath = dialog.SelectedPath;
M4N
+2  A: 

Have you tried setting the folder to System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)? This should do the trick.

John Källén
A: 

You could simply set the initial folder of the OpenFolderDialog to the result of System.Environment.GetFolderPath().

peSHIr