uigetfile adds "\\?" to a selected path that is technically too long
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Florian Berzsenyi
il 2 Mag 2022
Modificato: Florian Berzsenyi
il 2 Mag 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 Commenti
Image Analyst
il 2 Mag 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?
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
Scopri di più su File Operations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!