I have a WPF application where the user must choose a folder for an operation. I achieve this by opening a folder browser dialog when he clicks a button.
I want the dialog to both list external devices, like connected smartphones, and have a textbox where the user can enter a path to a folder and the dialog will be able to navigate to it, like the regular Windows dialogs work.
Currently I have:
FolderItem ShellBrowseForFolder()
{
Folder folder = shell.BrowseForFolder(Hwnd, "", 0, 0);
if (folder != null)
{
FolderItem fi = (folder as Folder3).Self;
return fi;
}
return null;
}
which I invoke by:
TargetFolderPath = ShellBrowseForFolder()?.Path;
This produces a folder browser dialog that looks like this:
This dialog lists external devices but the user can't just type in "C:\some dir" and have the dialog navigate to it.
I've also tried providing options for the IShellDispatch.BrowseForFolder
method (in accordance with these listed variants, after reading the MSDN article) like so:
Folder folder = shell.BrowseForFolder(Hwnd, "", 4, 0);
and
Folder folder = shell.BrowseForFolder(Hwnd, "", 0x00000004, 0);
but I haven't noticed anything changing.
The other dialog I have is:
readonly System.Windows.Forms.FolderBrowserDialog folderBrowser = new();
if (folderBrowser.ShowDialog() == DialogResult.OK)
folderPath = folderBrowser.SelectedPath;
This produces dis:
where the user CAN enter a path to a folder BUT this dialog does not show external devices, like connected smartphones.
Is there a way to get the best of both worlds?