Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do a make this type of select folder dialog in C#?

So I recently tried to the FolderBrowserDialog but much to my disappointment it was not like the following screenshot:

http://i.imgur.com/s2LHqxA.png

But instead it was formatted and as I think, hard to navigate with like this: http://i.imgur.com/rfSnt8C.png

How would I go about getting the other version where it's a dialog box asking for what folder to save to like the select file type natively, instead of what I think is this hard to navigate menu.

like image 673
Codingale Avatar asked Feb 11 '23 07:02

Codingale


1 Answers

The CommonOpenFileDialog class from the NuGet Package "Microsoft.WindowsAPICodePack-Shell" will answer your request.

Set IsFolderPicker property to true and that's it.

using Microsoft.WindowsAPICodePack.Dialogs;     

private bool SelectFolder(out string fileName)
{
    CommonOpenFileDialog dialog = new CommonOpenFileDialog();
    dialog.IsFolderPicker = true;
    if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
    {
        fileName = dialog.FileName;
        return true;
    }
    else
    {
        fileName = "";
        return false;
    }
}
like image 79
Tal Halamish Avatar answered Feb 12 '23 22:02

Tal Halamish