uigetfile adds "\\?" to a selected path that is technically too long
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Florian Berzsenyi
am 2 Mai 2022
Bearbeitet: Florian Berzsenyi
am 2 Mai 2022
I have found a curios error (feature) about uigetdir() that only triggers when two very specific conditions are met:
- A file path on a network drive must be > 255 chars long.
- The sytem limit to the path length must be 255 char. You cannot create directories longer than that but you can apparently still open these directories.
The result is that uigetdir() returns an extra "\\?\":
dir = '\\?\L:\Folder\To\AVery\Long\Path\With\A\file.xls' % path > 255 (e.g. length(dir) == 271)
%dirShouldBe = '\L:\Folder\...'
I enter the following in the Matlab console:
[file, dir] = uigetfile({'*.xl*;*.xlsx;*.xlsm;*.xlm','Excel Files'}, 'Select a file...')
Unfortunately, I cannot reproduce this error because I cannot create a directory with more than 255 chars on my machine, locally or on the network. Has anybody else noticed this kind of behavior?
2 Kommentare
Image Analyst
am 2 Mai 2022
dir is the name of a built-in function. Don't use it as the name of a variable. Call it folder instead. (This probably won't fix the problem though.)
If you can't create folders with path lengths longer than the OS limit, then how were they created?
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu File Operations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!