Explorer still limited by MAX_PATH
With the upcoming release of Windows 7 by Microsoft I am still surprised at a limitation of Explorer that has been around since explorer was first introduced with Windows 95. When Microsoft first introduced Windows 95 they included long filename support. This long filename support allowed Windows to store a filename of “up to 255 characters” while still maintaining compatibility with DOS and previous versions of Windows.
Remember filenames like LETTER~1.DOC and directories like PROGRA~1?
Well, believe it or not they still exist by default in Windows 7! You
can confirm this yourself by opening a command prompt and running the
dir /x
command. This will display files in the current directory
with both their long filenames and DOS compatible filenames. Of course
you can turn this filename generation off by setting the
appropriate registry keys.
Back with Windows 95 the Windows API generally provided only ANSI functions. ANSI strings were either single-byte or a variable-width multi-byte arrays. When Windows NT came along with its new kernel, all of the internal strings were represented in Unicode (double-width) character arrays.
Byte |
1 |
2 |
3 |
4 |
5 |
6 |
Data |
|
|
|
|
|
|
Byte |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
Data |
|
|
|
|
|
|
|
|
|
|
|
|
Along with the Unicode kernel, Windows NT also included updated APIs that used the new Unicode strings. So for every CreateFileA you now had a CreateFileW. To maintain backwards compatibility the original CreateFileA still had the limitation on the length of the path that Windows 95 did. Otherwise known by the macro of MAX_PATH which is defined as 260. Since CreateFileW was a new function, there was no backwards compatibility to maintain, so Microsoft provided a way to provide a path up to 32,676 characters. You can read more about the maximum path length on MSDN.
The drawback of still providing both APIs is that as applications pick and choose they can run into issues with the length of the path. Microsoft Word uses the CreateFileW function which allows them to create longer filenames than explorer can handle. I was hoping that in Windows 7 Explorer would finally be updated to use the Unicode CreateFile function… since Windows 95 was released over 14 years ago.
Unfortunately I ran into Explorer’s 260 character limitation just the other day. One of the deleted files resulted in a path of 273 characters long and the following dialog popped up:
Imported Comments
T800 on Thursday, January 6, 2011 at 12:41 AM wrote:
What is even more incredible is that they still didn't fix shell path handling functions such as PathFindExtension, they are still limited to MAX_PATH (256) characters, so I have to write my own if I want my code to be 21 century-compatible. I'll skip Win7 and stick with XP because nothing changes.
ken masters on Sunday, April 3, 2011 at 8:05 PM wrote:
「ストリートファイター」>「ヴァンガードプリンセス」