System.Windows.Forms.FolderBrowserDialog Class

Prompts the user to select a folder. This class cannot be inherited.

See Also: FolderBrowserDialog Members

Syntax

[System.ComponentModel.Designer("System.Windows.Forms.Design.FolderBrowserDialogDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")]
[System.ComponentModel.DefaultProperty("SelectedPath")]
[System.ComponentModel.DefaultEvent("HelpRequest")]
public sealed class FolderBrowserDialog : CommonDialog

Remarks

This class provides a way to prompt the user to browse, create, and eventually select a folder. Use this class when you only want to allow the user to select folders, not files. Browsing of the folders is done through a tree control. Only folders from the file system can be selected; virtual folders cannot.

Typically, after creating a new System.Windows.Forms.FolderBrowserDialog, you set the FolderBrowserDialog.RootFolder to the location from which to start browsing. Optionally, you can set the FolderBrowserDialog.SelectedPath to an absolute path of a subfolder of FolderBrowserDialog.RootFolder that will initially be selected. You can also optionally set the FolderBrowserDialog.Description property to provide additional instructions to the user. Finally, call the CommonDialog.ShowDialog method to display the dialog box to the user. When the dialog box is closed and the dialog box result from CommonDialog.ShowDialog is DialogResult.OK, the FolderBrowserDialog.SelectedPath will be a string containing the path to the selected folder.

You can use the FolderBrowserDialog.ShowNewFolderButton property to control if the user is able to create new folders with the New Folder button.

System.Windows.Forms.FolderBrowserDialog is a modal dialog box; therefore, when shown, it blocks the rest of the application until the user has chosen a folder. When a dialog box is displayed modally, no input (keyboard or mouse click) can occur except to objects on the dialog box. The program must hide or close the dialog box (usually in response to some user action) before input to the calling program can occur.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0