Lesser-known effect of path-length limitation in File Explorer in Windows 10

D

D.I.V.

Occasionally users encounter an error when dealing with files saved in deep directory structures, due to a limit on the maximum length of a path (including filename) in File Explorer, which is effectively 259 characters (excluding a required null terminator). I have seen the effects of this before when using either SyncToy or xcopy (I forget now which; maybe both).


It turns out that there are a couple of behaviours in Windows Explorer, under Windows 10 (with default settings; i.e. without a registry edit to remove the limit).


(1)

Normally it is possible to copy the path (including filename) of a file from Windows Explorer by either choosing "Copy as path" from the context menu or through Home > Copy path.

It turns out that if the length exceeds 260 characters (259 regular characters plus the obligatory <NUL> character), then Windows Explorer automatically copies the path in "short filename" format (a.k.a. "8.3 format" / "short name format").


Thus the path of
c:\long\path_name\....\no_really\very_long_path_name\the.long_file_name_01234567890123456789_foo.txt
might get copied to the clipboard as
c:\long\path_n~1\....\no_rea~2\very_l~1\thelon~4.txt

["...." just represents more of the path.]


(2)

Note that I can successfully copy files with longish names to folders with longish names to create paths that exceed the 260-character limit within File Explorer (even with the default settings)*. I can then open, copy and delete those files.

However, if I try to make a copy of the file in the same directory by dragging and dropping with the mouse, while Ctrl is depressed — so that File Explorer would want to append the suffix " - Copy" to the end (before the extension) — then the name gets truncated. Not to the 8.3 format, but enough to easily satisfy the path limit.

What do I mean by "easily satisfy"? What I found is that the new filename will be precisely 10 characters shorter than the maximum allowed (taking into account the entire path).


Thus
c:\long\path_name\....\no_really\very_long_path_name\the.long_file_name_01234567890123456789_foo.txt
might get duplicated as

c:\long\path_name\....\no_really\very_long_path_name\the.long_fil - Copy.txt

and manually editing this filename would allow it to be expanded as far as (e.g.)
c:\long\path_name\....\no_really\very_long_path_name\the.long_fil - Copy0123456789.txt
c:\long\path_name\....\no_really\very_long_path_name\0123456789the.long_fil - Copy.txt




I didn't find either of these behaviours documented anywhere else.

—DIV




System information:

OS Name Microsoft Windows 10 Pro for Workstations
Version 10.0.16299 Build 16299
System Type x64-based PC

* This functionality would implicitly be using an extended-length path, with a limitation of 32767 characters in total (with each constituent director or file's name being no more than ~255 characters).

Continue reading...
 
Back
Top Bottom