uigetfile adds "\\?" to a selected path that is technically too long
9 ビュー (過去 30 日間)
古いコメントを表示
Florian Berzsenyi
2022 年 5 月 2 日
編集済み: Florian Berzsenyi
2022 年 5 月 2 日
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 件のコメント
Image Analyst
2022 年 5 月 2 日
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?
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!