locked
Common dialog for selecting a folder - where is it? RRS feed

  • Question

  • Hi,
    this must be a very easy one, but I just don't find it: where is the common dialog for letting a user select a folder? I looked at Microsoft.Win32.OpenFileDialog, but that's for selecting files... Surely, there must be one for selecting a folder?
    Thanks,
    Koen
    • Edited by KoenT Wednesday, June 4, 2008 8:15 PM clearer question
    Wednesday, June 4, 2008 4:58 PM

Answers

  • Unfortunately, WPF doesn't have a folder browser dialog.  I'll open up a bug for that.

    If you are using a standalone app or a full trust .xbap, you can use System.Windows.Forms.FolderBrowserDialog.  You'll need to add a reference to System.Windows.Forms in your project, but it should work.

    Andre
    • Marked as answer by KoenT Wednesday, June 4, 2008 8:25 PM
    Wednesday, June 4, 2008 8:19 PM

All replies

  • Unfortunately, WPF doesn't have a folder browser dialog.  I'll open up a bug for that.

    If you are using a standalone app or a full trust .xbap, you can use System.Windows.Forms.FolderBrowserDialog.  You'll need to add a reference to System.Windows.Forms in your project, but it should work.

    Andre
    • Marked as answer by KoenT Wednesday, June 4, 2008 8:25 PM
    Wednesday, June 4, 2008 8:19 PM
  • Wow! I almost can't believe this... I thought WPF was pretty mature by now...
    But thanks for the info, at least that's a workaround.
    I hope your bug submisson will be followed-up quickly.
    Koen
    • Marked as answer by KoenT Wednesday, June 4, 2008 8:24 PM
    • Unmarked as answer by KoenT Wednesday, June 4, 2008 8:25 PM
    Wednesday, June 4, 2008 8:23 PM
  • I was wondering: to avoid having to add WinForms stuff to my application, could I also somehow use this call to select a folder:
    SHBrowseForFolder
    http://msdn.microsoft.com/en-us/library/bb762115(VS.85).aspx    ?

    If so, how exactly would I call that from my C#/WPF code?

    Koen
    Monday, June 9, 2008 1:22 PM
  • To call SHBrowseForFolder from C# code, you'd need to do about 8 PInvoke calls to mimic what that sample you reference is doing.  It's possible, but it would be a lot of effort.  It seems like going the WinForms route is a better tradeoff.

    Andre
    Tuesday, June 24, 2008 6:23 PM
  • There is a "purely WPF" user control which provides the functionality of the old WinForms folder browser at ttp://londonelegance.com/tyburn-consultancy/wpf/
    • Proposed as answer by Punnone Monday, June 18, 2012 3:59 AM
    • Unproposed as answer by Punnone Monday, June 18, 2012 3:59 AM
    Saturday, June 6, 2009 5:01 PM
  • There is a "purely WPF" user control which provides the functionality of the old WinForms folder browser at ttp://londonelegance.com/tyburn-consultancy/wpf/

    Thanks for the example. 

    However, the GUI part looks like some poor graphic from a old Windows 3.1 game and doesn't look very WPF-ish.  So unfortunately you cannot just add this code to your program, you have to write a new GUI for it.

    Microsoft makes me pleased that BSD exists.
    Monday, February 8, 2010 2:41 PM
  • Here is tiny fully managed implementation of folder picker dialog:

    http://tillias.wordpress.com/2011/03/20/net-4-folder-picker-folder-browser/


    God bless you!
    • Proposed as answer by tillias Sunday, March 20, 2011 8:01 AM
    Sunday, March 20, 2011 8:01 AM
  • I've been having the same trouble finding a common dialog so I implemented a solution out of two others that I found on the Internet. Please have a look at:

    http://filesystemcontrols.codeplex.com/

    Wednesday, October 5, 2011 7:08 AM
  • Hey, so this was 4 years ago, has anything changed on this front? Or are we still using the Windows Forms app?
    Friday, March 1, 2013 8:52 AM
  • There is a handfull or Dialogs and Controll that don't have a WPF equivalent yet. For those, you can just use the WinForms equivalant.

    http://msdn.microsoft.com/en-us/library/ms750559.aspx

    Some Dialogs also fall under those elements missing in WPF, but jsut using the WinForms equvalent solves that.


    Let's talk about MVVM: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b1a8bf14-4acd-4d77-9df8-bdb95b02dbe2

    Friday, March 1, 2013 12:40 PM
  • Thanks and GOD bless you to :-)

    JESUS is LORD!!!
    Tuesday, August 27, 2013 9:03 AM
  • Hi all, 

    I read that we have to use the WinForm version of the folderBrowserDialog since there is no WPF version available yet. 

    What if we want to customize it like it is possible with dialogs available from commondialog?

    thanks

    • Edited by Shomron Tuesday, July 3, 2018 2:38 PM
    Tuesday, July 3, 2018 2:37 PM