10

In Visual Studio 2008 there is a folder browser dialog that looks like this (very similar to file open dialog):

Dialog

Does anyone know how to invoke it from code?

Glorfindel
  • 20,880
  • 13
  • 75
  • 99
Alex Reitbort
  • 13,315
  • 1
  • 38
  • 61

4 Answers4

20

If you're using C#, this solution is for you. Source code provided here: http://www.lyquidity.com/devblog/?p=136 (.NET Win 7-style folder select dialog).

You don't need to use a whole library like VistaBridge, or a Windows API code pack, to get a nice Folder Dialogue, just two small source files. Gives you a nice folder dialogue like this:

leetNightshade
  • 2,517
  • 2
  • 33
  • 47
  • 3
    This solution works without using VistaBridge and it provides a fallback for XP and older. – Alex Essilfie Jun 09 '13 at 14:47
  • This is a great solution. It simply works and unlike Windows API code pack this has no license restrictions. Thank you! – jetstream96 Dec 29 '16 at 09:01
  • It should be mentioned that the Reflector class is from [Front-End for Dosbox](http://code.google.com/p/fed/) and this is GPL v2. So it *has* license restrictions. – Gerd K Mar 31 '22 at 13:33
5

At the end I just used the VistaBridge library to open it.

Alex Reitbort
  • 13,315
  • 1
  • 38
  • 61
1

Is this the pinvoke of SHBrowseForFolder, with the BIF_NEWDIALOGSTYLE style? If so there is an example on that page.

Preet Sangha
  • 62,844
  • 17
  • 138
  • 209
-1

Drag a FolderBrowserDialog component from the Dialogs tab of the Toolbox to the form. Add this code to you button handler.

if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
        {
            this.label1.Text = folderBrowserDialog1.SelectedPath;
        }
Sorantis
  • 14,120
  • 4
  • 30
  • 36