Stopping too long filenames in Windows Server 2003

fileswindows-server-2003

We're finding a problem with long filenames, usually on "My Documents" or on shared drives.

Basically, it seems that a document could be written that has a very long filename, and saved say in "My Documents". Which is fine on that computer, the document is "My Documents\verlylongfilename".

The problem arises when you got to the server the files are stored on, and the path changes to "e:\All Users\Staff Folders\JSmith\verylongfilename", which pushes the character count over what explorer can do anything with.

The only way I've found to "remove" or rename these files is to map through to the folder, but that's completely pointless if you want to move a group of folders.

Is this just a restriction we have to live with and fix as we find, or is there another way to access these files, or even to stop the original users from saving filenames over say 30 characters? A GPO setting maybe?

Best Answer

The NTFS file system supports paths up to about 32767 Unicode characters with each path component (directory or filename) up to 255 characters long. But Windows Explorer and most other Win32 applications only support 255 characters in the path.

You could use robocopy, a free tool from Microsoft that fully supports long path names (longer than 256 characters). Here is documented how to use robocopy listing all switches and options.


Here's an excerpt from article on MSDN that explains why many programs limit paths to 255 characters:

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, components separated by backslashes, and a terminating null character. For example, the maximum path on drive D is

    D:\some 256 character path string<NUL>

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.)