SharePoint Internals – Hristo Pavlov’s Blog

13 November, 2008

The MAX_PATH in SharePoint

After working with some really long path names in a SharePoint document library with many nested folders and subfolders I got some interesting findings that I’d like to share with you.

Firstly according to Microsoft the maximum allowed characters in a file path should not exceed 260 as per this KB article:

http://support.microsoft.com/kb/894630

But the article is not specific in how you count the characters. After doing the tests myself this is what I found. Firstly you have to convert the path into UTF-16, but this will only make a difference if you are using non Latin characters in your URL. Secondly you will have to URL-Decode the path i.e. replace all %20 with a space and the other %xx escape sequences with their corresponding ASCII character. And finally you need to remove the server name and the first leading slash from the URL. If the path to your file is:

 http://myserver.domain.com/managed-path/sitecoll/web%201/web%202/lib%201/folder%201/…./file1.doc

you need to count:

managed-path/sitecoll/web 1/web 2/lib 1/folder 1/…./file1.doc

you will be only able to upload the file in SharePoint if the number of counted characters does not exceed 260. The same results have been reported by Tim Jones in this blog entry:

http://simplyaprogrammer.com/2008/05/importing-files-into-sharepoint.html

But things don’t end here. SharePoint has a tight integration with Microsoft Office and allows you to check out and edit Office documents when you click on the links inside document libraries. Usually (with Office 2003 and Office 2007) when you click on a Office document you get a pop-up like the one below:

longpath2

However when you are trying to open files which full path length is getting closer to the maximum allowed by SharePoint you may start getting the standard IE file download dialog instead of the nicer Read only/Edit dialog:

longpath

The reason for this happening is that the component that is showing up the dialog and is responsible for the integration has a different limits on the maximum path than SharePoint. This component is an ActiveX control called “SharePoint.OpenDocuments” and is installed when you install MS Office if you choose the “Windows SharePoint Services Support” install option.

The limit for this component is again 260 characters, but this is 260 URL-Encoded characters for the full URL including the server name where a space (%20) counts for 3 characters rather than 1.

So this means that SharePoint will allow you to upload documents that will have a path that is too long for the MS Office SharePoint Integration to be able open them.

Blog at WordPress.com.