Browse for a directory in C#


Question

How can I present a control to the user that allows him/her to select a directory?

There doesn't seem to be any native .net controls which do this?

1
57
10/23/2018 10:52:28 AM

Accepted Answer

The FolderBrowserDialog class is the best option.

59
1/17/2016 12:54:56 PM

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

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon