Category : C# | Author : Chtiwi Malek | First posted : 6/13/2012 | Updated : 12/6/2012
Tags : winforms, c#, .net, folder, file, browse, select, disk, find, dialog
Browse for a Folder in C# Winforms

Browse for a Folder in C# Winforms

This is a simple code showing how to display a "browse for folder" dialog to select a folder and get the full path.

Within the directory chooser you can also create a new folder if the folder you want to select doesn't exist.
// New FolderBrowserDialog instance
FolderBrowserDialog Fld = new FolderBrowserDialog();

// Set initial selected folder
Fld.SelectedPath = curfolder.Text;

// Show the "Make new folder" button
Fld.ShowNewFolderButton = true;

if (Fld.ShowDialog() == DialogResult.OK)
{
    // Select successful
    MessageBox.Show("The folder you selected is : " + Fld.SelectedPath);
    curfolder.Text = Fld.SelectedPath;
}
else
{
    // Selection canceled
    MessageBox.Show("Operation canceled.");
}
Leave a Comment:
Name :
Email : * will not be shown
Title :
Comment :