I'm writing a program that needs to read in files from anywhere on the system. Some users of the program have paths over the 260 character limit. The OpenFileDialog
doesn't work with files with paths over 260 characters.
I've tried using both System.Windows.Forms.OpenFileDialog
and Microsoft.Win32.OpenFileDialog
. In the case of the former, when I click "open" after I've navigated to and selected the file, the window doesn't close and the program doesn't continue. In the case of the latter, the window will close when I click "open", but the path is an empty string.
I've updated the registry on my computer. I've edited the application manifest file. I would try to prepend the "//?/" string to my paths, but there are no paths to which to prepend.
var dialog = new OpenFileDialog
{
// initialize dialog
}
if (dialog.ShowDialog() == DialogResult.OK) // DialogResult.OK replaced with true if using Microsoft.Win32.OpenFileDialog
{
// if when using System.Windows.Forms.OpenFileDialog, I will never get to this point
// if using Microsoft.Win32.OpenFileDialog, I will get here but dialog.FileNames will be empty
}
I'd expect the above code to work the same with long and short paths if I've updated the registry and the app manifest. I'm suspecting that this just isn't supported, but all of my searches have revealed people providing a solution that either doesn't work or only works in specific cases.