-1

Can I Use Openfiledialog to browser folder? Because I really hate using FolderBrowserDialog().

Ken White
  • 123,280
  • 14
  • 225
  • 444
Spencer
  • 71
  • 6
  • By `FolderBrowserDialog` - are you referring to the Windows XP-era single-tree-view dialog? Or are you referring to the Windows 7-era OFD-style folder browser? – Dai Jul 18 '22 at 23:40

1 Answers1

1

I had the same issue in one of my projects and found a solution. You can use it if you get the Microsoft.WindowsAPICodePack-Shell nuget package and use the Microsoft.WindowsAPICodePack.Dialogs namespace. Use it as such:

CommonOpenFileDialog dialog = new CommonOpenFileDialog
    {
            IsFolderPicker = true
    };
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
    {
            // the selected directory is in dialog.FileName
    }
Ekas
  • 150
  • 8