c# - How do I use OpenFileDialog to select a folder? - Stack Overflow

PHOTO EMBED

Mon Feb 27 2023 05:14:34 GMT+0000 (Coordinated Universal Time)

Saved by @javicinhio #cs

OpenFileDialog folderBrowser = new OpenFileDialog();
// Set validate names and check file exists to false otherwise windows will
// not let you select "Folder Selection."
folderBrowser.ValidateNames = false;
folderBrowser.CheckFileExists = false;
folderBrowser.CheckPathExists = true;
// Always default to Folder Selection.
folderBrowser.FileName = "Folder Selection.";
if (folderBrowser.ShowDialog() == DialogResult.OK)
{
    string folderPath = Path.GetDirectoryName(folderBrowser.FileName);
    // ...
}
content_copyCOPY

https://stackoverflow.com/questions/11624298/how-do-i-use-openfiledialog-to-select-a-folder