Browse for a directory using FolderBrowserDialog in Winforms

When developing a Windows Application , the developers can use the FolderBrowserDialog control which lets the user to select a directory.

Browse for a directory using FolderBrowserDialog in Winforms

Below is a sample code snippet demonstrating how to use the FolderBrowserDialog control using C# .

string FolderGKPath = "";
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
    FolderGKPath  = folderBrowserDialog.SelectedPath ;
}

The SelectedPath property of the FolderBrowserDialog control returns the path of the directory that was selected.

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...