Search code examples
c#wpffolderbrowserdialog

VistaFolderBrowserDialog does not start with the correct folder


I would like to use a Folder Browse Dialog for WPF, but there does not seem to be such an essential class for WPF.

Some recommend to use System.Windows.Forms.FolderBrowserDialog but this is a really awful dialog.

I tried Ookii.Dialogs.Wpf.VistaFolderBrowserDialog:

Ookii.Dialogs.Wpf.VistaFolderBrowserDialog dlg = new VistaFolderBrowserDialog();
dlg.SelectedPath = path;
dlg.ShowDialog();

but setting the SelectedPath does not set the start folder when the Dialog opens which is essential for my program.

How can I get VistaFolderBrowserDialog to open in the correct folder?


Solution

  • I ended up using the Codeplex project WPF Native Folder Browser:

    WPFFolderBrowser.WPFFolderBrowserDialog dlg = new WPFFolderBrowserDialog();
    dlg.InitialDirectory = path;
    bool? pathWasSelected = dlg.ShowDialog();
    string selectedPath = null;
    if(pathWasSelected == true) 
        selectedPath = dlg.FileName;