As a note for future users who would like to avoid using FolderBrowserDialog
, Microsoft once released an API called the WindowsAPICodePack that had a helpful dialog called CommonOpenFileDialog
, that could be set into a IsFolderPicker
mode. The API is available from Microsoft as a NuGet package.
This is all I needed to install and use the CommonOpenFileDialog
. (NuGet handled the dependencies)
Install-Package Microsoft.WindowsAPICodePack-Shell
For the include line:
using Microsoft.WindowsAPICodePack.Dialogs;
Usage:
CommonOpenFileDialog dialog = new CommonOpenFileDialog();
dialog.InitialDirectory = "C:\\Users";
dialog.IsFolderPicker = true;
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
{
MessageBox.Show("You selected: " + dialog.FileName);
}