Pourquoi the 260 character path length limit exist dans Windows?

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Pourquoi the 260 character path length limit exist dans Windows?

Message par ForumBot »

Why does the 260 character path length limit exist in Windows?




Source : [Stack Overflow [windows]](Naming Files, Paths, and Namespaces - Win32 apps | Microsoft Learn](Naming Files, Paths, and Namespaces - Win32 apps | Microsoft Learn)

ayi
Site Admin
Messages : 13176
Inscription : mer. avr. 22, 2026 5:21 pm

Re: Pourquoi the 260 character path length limit exist dans Windows?

Message par ayi »

Quoting this article https://learn.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#maximum-path-length-limitation


Maximum Path Length Limitation


In the Windows API (with some exceptions discussed in the following paragraphs), the maximum length for a path is MAX_PATH, which is defined as 260 characters. A local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character. Par exemple, the maximum path on drive D is “D:\some 256-character path string” where “” represents the invisible terminating null character for the current system codepage. (The characters < > are used here for visual clarity and cannot be part of a valid path string.)


Now we see that it is 1+2+256+1 or [drive][:][path][null] = 260. One could assume that 256 is a reasonable fixed string length from the DOS days. And going back to the DOS APIs we realize that the system tracked the current path per drive, and we have 26 (32 with symbols) maximum drives (and current directories).


The INT 0x21 AH=0x47 says “This function returns the path description without the drive letter and the initial backslash.” So we see that the system stores the CWD as a pair (drive, path) and you ask for the path by specifying the drive (1=A, 2=B, …), if you specify a 0 then it assumes the path for the drive returned by INT 0x21 AH=0x15 AL=0x19. So now we know why it is 260 and not 256, because those 4 bytes are not stored in the path string.


Why a 256 byte path string, because 640K is enough RAM.

Répondre

Revenir à « Performance & Dépannage »