FolderBrowserDialog Control in C#.Net
The FolderBrowserDialog control is used to browse and select a folder. FolderBrowser class in framework provides the FolderBrowserDialog control.
How to use FolderBrowserDialog Control
Drag and drop FolderBrowserDialog control from toolbox on the window Form.
Drag and drop button and textbox, a button for showing browser dialog and textbox to show the selected path.
Code:
Write the code on the Button click event.
Double click on Click event to open Button click event handler.
private void btnFolderBrowser_Click(object sender, EventArgs e)
{
// folderBrowserDialog will open
folderBrowserDialog1.ShowDialog();
//selected pathe in folderBrowserDialog will show in textbox
textBox1.Text = folderBrowserDialog1.SelectedPath;
}
Run the project
When you click BrowseFile button then FolderBrowserDialog will open.
Select Folder
When you select File and click the ok button then the selected path will show in the textbox.
Leave Comment