MZ-Tools Articles Series: HOWTO: Use the Browse for Folder dialog of Visual Studio from a package

Another question in the MSDN VSX Forum about the browser for folder dialog was intriguing enough for me to investigate. If you are using the .NET Framework since version 1.0 (like me), you may remember that that version didn’t provide a class, you had to use the native class of the Win32 API Shell, which was tricky. The FolderBrowserDialog was added in .NET Framework 1.1, and since then it has this appearance:

NetFolderBrowserDialog

Despite being in Spanish (the computer that I am using to write this post), you can guess that it provides a title, a description, a treeview and an optional button to allow the creation of a new folder without leaving the dialog.

However, Visual Studio uses this other dialog to select a folder in several places:

VisualStudioFolderBrowserDialog

Again, despite being in Spanish, you can guess that it provides a treeview to the left and a listview to the right, along with the button to create a new folder and, overall, somewhat better usability.

So, the question was how to leverage that Visual Studio dialog from a package. The answer lies in the IVsUIShell.GetDirectoryViaBrowseDlg method, and in this new article of mine you have a working example, because the API is awful, with arrays of structures, memory allocation, marshaling, etc:

HOWTO: Use the Browse for Folder dialog of Visual Studio from a package

One thought on “MZ-Tools Articles Series: HOWTO: Use the Browse for Folder dialog of Visual Studio from a package”

Comments are closed.