Wednesday, August 9, 2006

SP2003: Path/File Name Character Length and potential file loss

SharePoint Document Libraries have certain limits on the number of characters in a file name (128), and the number of characters in a file path(260). Unfortunately there are ways to violate these limits and potentially lose files

If you exceede these numbers, you'll get a warning stating:
The specified file or folder name is too long. The URL path for all files and folders must be 260 characters or less (and no more than 128 characters for any single file or folder name in the URL). Please type a shorter file or folder name.

http://support.microsoft.com/?kbid=894630

Apparently the character length limits are there to support Office applications which have a MAX_PATH limit.

Because of this limit, it is possible to lose entire folders of files if you attempt to move them in the Explorer View, and the new path goes over the 260 character limit.
For example, you have a folder of 20 documents with varying file name lenghts. Most of the files have 10 character file names, but the longest file name is 55 characters long. The rest of the path for this folder is 200 characters, making this longest file name have a path of 255 characters, just inside the 260 limit.
You go into Explorer View, and Cut this folder of documents, and paste it into a new path which is 210 characters long. This puts the longest file over the limit. The problem is, the folder has already been Cut and deleted from the old location. It won't paste into the new location because of the limit. The entire folder disappears, inlucing those files that were still within the character limit.

This is a serious flaw, and there is no easy way to restore these files, other than going to backup.
This doesn't seem to be a problem when cutting and pasting a single file.... if it is over the character length it will simply give you an error message. It is only a problem with folders that contain 1 or more files that exceed the limit.