O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required