The FolderBrowserDialog provided by .NET is just plain bad, the one that comes standard with Vista/7 is so much better..
So, download Windows API Code Pack, and then
using Microsoft.WindowsAPICodePack.Dialogs;
and
using (Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog folderDialog = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog())
{
folderDialog.IsFolderPicker = true;
if (folderDialog.ShowDialog() == CommonFileDialogResult.Ok)
{
string folder = folderDialog.FileName;
}
}
This will give you a dialog like this:

You failed to mention one thing. You have to add two references in your solution explorer.
ReplyDelete1. Microsoft.WindowsAPICodePack
2. Microsoft.WindowsAPICodePack.Shell
That should be obvious.
DeleteThanks for this.
ReplyDelete