I'm using the GetOpenFileName API, or in my case MFC's CFileDialog to open files, pretty much like it's shown here (except for a single file selection -- i.e. I provided my own longer buffer in m_ofn.lpstrFile
.)
It works fine, except when a user picks a file whose path becomes longer than MAX_PATH - 1
(or 259) characters. In that case the following happens:
On my Windows 8.1, it converts the user selected path into an archaic 8.3 short file format: "C:\TESTDE~1\NEWFOL~1"
On Windows XP I can't even select anything, I get this:
So I'm curious, since the OS itself supports long Unicode paths, prefixed with \\?\
(including XP) is there any way to coax GetOpenFileName to return paths in that format as well and not be limited by 259 characters?
For example, Explorer won't let you create a folder name that ends up with a path that is longer than 260 characters and you can delete folders or files in folders that exceed the MAX_PATH limit. It's an inherent issue in Windows because the base Windows file APIs by default don't recognize these long paths.
A file path is the total file name that consists of the local disk name, root folder name, names of folders/subfolders, file name, and file extension. A long path is the one that exceeds 260 characters.
Windows file dialogs, even the new Vista IFileDialog
, will not return file names longer than MAX_PATH
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With