Here is the explanation how restriction applied while uploading and editing.
For example my site URL is: http://wfeone/ (14)
The document library I have created: Queen/ (6)
Folder created under Queen: 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789/ (101)
Sub-folder : 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789/ (101)
Sub-folder : 012345678901234567890123456789/ (31)
14+6+101+101+31 = 253
Complete length of the below URL is 253 characters
To edit the document, it must have only 6 characters in length (a.docx), if you upload any document which is 7 in length (ab.docx) cannot be editable. We get the following error message.
"The URL for this file is too long for the application. A temporary copy of this file will be opened on your computer. You must save this copy as a new file"
While uploading we use different mechanism to calculate length.
We do not count the site URL http://wfeone/ (14), the count starts from document library Queen/, so the total length would be 239 and you are allowed to upload a document which is 20 (0123456789012345.docx) in length, you cannot upload a document which is 21 characters. You will get the following error message.
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.
Troubleshoot issues with Windows SharePoint Services.
So, we have restrictions in both sides, while uploading and editing. But it works in different way, site URL is not counted while uploading.
select * from sites
select * from webs
copy the SiteId from the above query and replace it with the below query.
select 'http://selvag/' + DirName + '/' + LeafName as url, LEN('http://selvag/' + DirName + '/' + LeafName) as urllength from alldocs where siteid = '9BE4D0E8-ADC6-4C3F-946B-08D6748CC123' and LEN('http://selvag/' + DirName + '/' + LeafName) >200 order by urllength desc
We can create custom event handler which can count the site URL as well.
Some of the reference links are here …