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.