.NET WPF Folder Picker / Folder Browser

It has been so many times when I’ve needed managed Folder Picker dialog that I’ve decided to write my own.

Library can be downloaded here. You can browse and download sources here

Update 15/12/2011:

Now there are several contributors (+davidbitton) and we’re moving towards GitHub here https://github.com/tillias/wpFolderPicker. NuGet package will be ready soon.

Before we start here is the short demo:

Folder picker demo

Here is the screenshot of library references (no more use of Windows.Forms — only WPF managed code):

Library references

Finally here is sample usage:

Usage sample

I hope screenshots say more then text. Next page we’ll talk about internals and implementation.

Posted in .NET. Tags: , . 30 Comments »

30 Responses to “.NET WPF Folder Picker / Folder Browser”

  1. Canyou Says:

    is it free ? no license ?

    • tillias Says:

      Yep it’s under GNU GPL v3 so you can use it both for open source and commercial software. Feel free to modify for your needs or ask for features

      • Jared Says:


        Thanks for pointing me to this on my blog. However, I cannot use it because it is GPL. You statement in the comment above is not accurate.

        Actually the GPL means you CANNOT use it for free in Commercial software.

        If you want it to be free to use in Commercial software, you need to use a more permissive BSD license.

        I have post about these license differences.
        Differences between the BSD/FreeBSD Copyrights and the GNU Public License (GPL)

        Reading your comment, it seems like you intended it to be a free license that can be used for commerically. If that is your intent, you must change the license to be a more permissive license. BSD, MIT, etc…

      • tillias Says:

        Thanks for you clarification. I will update licensing ASAP.

      • Rutix Says:

        Jared, that is not really correct. You can use GPL for free in Commercial Software. It only means that that commercial software automaticly also gets the GPL license and the GPL license also applies to that software. A direct comment from the GPL license site:

        Does the GPL allow me to sell copies of the program for money? (#DoesTheGPLAllowMoney)
        – Yes, the GPL allows everyone to do this. The right to sell copies is part of the definition of free software. Except in one special situation, there is no limit on what price you can charge. (The one exception is the required written offer to provide source code that must accompany binary-only release.)

        Source: http://www.gnu.org/licenses/gpl-faq.html#DoesTheGPLAllowMoney

  2. Oliver Says:

    Nice work! I just have one issue (maybe the problem is on my side ;-)): When i choose to “Cancel” the folder select dialog and then try to open it again – i.e. hit the ‘Browse…’ – Button again – i get an InvalidOperationException when i execute dlg.ShowDialog():
    “DialogResult can be set only after Window is created and shown as dialog.”
    Any idea?

    • tillias Says:

      I think you use dialog.Show() instead if dialog.ShowDialog(). Can you show me the usage code please?

      • Oliver Says:

        Sure, here’s the code snippet:

        private void btnSelInDir_Click(object sender, RoutedEventArgs e) {
        FolderPickerDialog dlg = new FolderPickerDialog();
        //dlg.Title = “Select Input Directory”;
        if (dlg.ShowDialog() == true) {
        txfInputDir.Text = dlg.SelectedPath;

        Do i need to do some cleanup/dispose?

      • tillias Says:

        Very strange. I’ve added following internal check while closing dialog:
        private void CancelButton_Click(object sender, RoutedEventArgs e)
        if (ComponentDispatcher.IsThreadModal)
        DialogResult = false;
        This is done according to http://stackoverflow.com/questions/1378602/setting-dialogresult-only-after-showdialog-in-wpf

        Please download new binray package from google.code (links on the first page are updated) and let me know wheter it helps or not. Thanks!

  3. Oliver Says:

    The new version solved the problem. Thank you!

    • Suchismita Chakraborty Says:

      Can you please tell me where is the new version available? i am not able to find it in google.code..thanks in advance.

  4. John Says:

    I think there’s a problem with your read-only SVN checkout link as I cannot get it to work.

  5. Maria Simlinger Says:


    First thanks for providing this solution.

    Is it possible to set a Startup value for the SelectedPath prior to opening the Dialog? This Property is read-only (r133).


    • tillias Says:

      Hello Maria! Thanks for request! I’ve created issue http://code.google.com/p/wmediacatalog/issues/detail?id=38 and will fix it in several two days. You can monitor status of your issue using link given above.

      I will provide additional InitialPath property with public setter which will allow you to start dialog with expected initial folder expanded. Though I still suggest to leave SelectedPath read-only to avoid confusion.

  6. kyosuke Says:

    Hello is the multiple selected folders features are there for this lib?

  7. Rossano Says:

    Hi Tillias,

    very good works thanks for providing it!
    I am interested on the improvement identified by Maria, and I see it is fixed, can you tell me when it will be available to download?


  8. Tim Says:

    Hi Tillias,
    Thanks for this! Nice work.

  9. Michael Says:

    Very nice.

    I too am worried about the GPL. It still says GPL on Google Code.

    Also, one feature that would be great is a new folder button.

    If the license changes, I may try to add some features to it, because I would use it in my projects.

    • tillias Says:

      It makes sense to change licensing model for FolderPicker to BSD license. I’ve created issue for new folder functionality

  10. Kris C Says:

    Is there a way you can sign the posted assembly so it can be used in projects that are signed? Without this I can’t use the dll directly.

  11. David B. Bitton Says:

    How about creating a NuGet package for this? Thanks!

  12. davidbitton Says:

    I’m in the process of modifying FolderPickerControl. I made InitialPath a DependencyProperty so I could set it via binding. I’ve also ran through the code with ReSharper and made the usual suggested changes (and Childs is now Children). Next step is to code it such that the InitialPath can be the root. What I’m not understanding is the use of Tasks in the initial update to the UI. From what I can see from setting a breakpoint inside the ContinueWith, you’re waiting for the tree to become visible before painting it. Is that correct? I put the tree in an Expander, so the ContinueWith block isn’t called until the Expander is expanded. Why wait? You’ve already loaded the initial folders under the drive. Thanks!

    • tillias Says:

      Tasks are needed to handle container generation stuff. Without them we can’t implement lazy loading. Feel free to commit changes — I’ll provide you with google.code credentials — just send me your google e-mail

      • davidbitton Says:

        I understand lazy loading but why this and not just hook the Expanded event? Also, have you considered using Reactive Framework in lieu of Tasks? Also, have you thought about moving to GitHub so I can fork the project? Thanks!

      • tillias Says:


        Have you tested it with Expanded event? Does it work? I used Tasks to wait until ContainerGenerator finished generating treeView items. What is the advantage of Reactive Framework? I think it should be as simple and lightweight as possible by the means of external dependencies.

        And yes — gitHub is nice place to store it. Though we should think about default MS icons and licensing in case of moving to gitHub. Can you please advise about it?

      • davidbitton Says:

        As far as icons go, I’ve used Win32 calls for that. I use SHGetFileInfo(…). Now using p/invoke precludes the lib’s use in mono. Not sure if that matters. Regarding Reactive Framework, I find that it makes subscribing to asynch operation very easy. Sure, the lib would then have a dependence on another lib, but if coders rely on NuGet, then it just becomes a dependency and Rx is loaded as necessary. Email me so we can discuss further.

  13. George Hahn Says:

    It would be awesome to see this on NuGet. Any chance of that happening?

  14. Fletcher J Says:

    If you want the search to be non case sensitive (i.e. dlg.InitialPath = “c:\\windows” ) – which currently doesn’t work because the match is case sensitive – just change line 237 of FolderPickerControl.xaml.cs as follows:

    var childItem = dirContainer.Childs.Where(c => c.Name.ToUpper() == currentDir.Name.ToUpper()).FirstOrDefault();

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: