Search code examples
c#.netwpfdialogookii

Ookii VistaFolderBrowserDialog and getting selected folder


I am trying to use the Ookii dialog pack to spawn the new Vista style folder selection dialog. That all works with this simple code:

VistaFolderBrowserDialog dlg = new VistaFolderBrowserDialog();
dlg.SelectedPath = Properties.Settings.Default.StoreFolder;
dlg.ShowNewFolderButton = true;
dlg.ShowDialog();

However, I cannot see any way of knowing when the user has selected a folder as there are no events on this object. I could poll for changes in SelectedPath, but that seems a terribly inefficient way of doing things.

Is there some generic C# trick I have missed to enable me to know when a user has selected a folder and therefore update other fields appropriately?


Solution

  • Try

    VistaFolderBrowserDialog dlg = new VistaFolderBrowserDialog();
    dlg.SelectedPath = Properties.Settings.Default.StoreFolder;
    dlg.ShowNewFolderButton = true;
    
    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
    {
        string path = dlg.SelectedPath;
    }