I'm trying to use CommonOpenFileDialog
to allow users to select a folder, but also view the files that within the folder in the dialog. Currently my code allows the user to only select a folder, but files within it are hidden, which causes users to think they have selected a wrong (empty) folder.
using (var dlg = new CommonOpenFileDialog()
{
Title = "Select folder to import from",
AllowNonFileSystemItems = true,
IsFolderPicker = true,
EnsurePathExists = true,
Multiselect = false,
ShowPlacesList = true
})
{
if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
{
//Do things with the selected folder and the files within it...
}
}
How can I achieve my goal for applications targeting Windows 10?
NOTE: There is a very similar question titled "How can I make CommonOpenFileDialog select folders only, but still show files?". This question already has good answers, however, none of the solutions work in Windows 10. Because the existing question is outdated (asked over 9 years ago) and doesn't apply for Windows 10, this question is specifically asking for a solution that works on a Windows 10 device.