Display the Standard Directory Selection Dialog Box

Problem

You want to display a standard dialog box for directory selection.

Solution

In .NET 1.1, use the FolderBrowserDialog class in the System.Windows.Forms namespace. In .NET 1.0, you must derive a class from System. Windows.Forms.Design.FolderNameEditor so that you can use the protected FolderBrowser class it contains.

Discussion

The .NET Framework includes several classes that wrap standard dialog boxes, such as the OpenFileDialog and SaveFileDialog classes. However, .NET 1.0 does not include any class for selecting a directory. .NET 1.1 (included with Visual Studio .NET 2003) resolves this problem by adding the FolderBrowserDialog class. This recipe demonstrates how to use this class, and how ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.