The Error
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
The Problem

I had a little shocker yesterday while trying to publish a project. Visual Studio informed me that I had a full file path that was just too long to handle. It also told me that Windows uses a magic number of 260 characters to gauge these issues?

Unfortunate Answer
After doing a lot of digging, there is no “real” answer to this problem. There is a very unsavory solution which is to shorten your file names, reduce the number of directories you are using or rename some of your directories so the over all length is shortened. I was forced to go into TFS and rename some directories because fuck if I was going to rename my projects and its objects. This is unfair and rather ridiculous on Microsoft’s part.
Taking a Stab at Microsoft
I love Microsoft and everything, but holy shit guys really? I get it – I am a programmer too and there are certain architectural decisions we made a long time ago that are biting us in the ass now, but at least some of us make more effort in solving the situation or giving their clients a goddamn work around. This is totally unprofessional. The only reason I am even having this problem is because during a publish Visual Studio 2012 is designed to copy my files to a temporary directory; which guess? INCREASES MY FILE PATH LENGTH! So it isn’t even my fault! I didn’t ask that my files be copied to a temporary directory!
This is the path that is being complained about:
D:Devabctfs01.xyz.localMiscellaneousMisc ProjectsabcInternalToolsabcIntranetApplicationabcWebResourceWebAppobjDebugPackagePackageTmpServiceReferencesAPIabcdeServiceReferenceabcWebResourceWebApp.APIabcdeServiceReference.SpecificObjectNameODS.datasource

The red part is the temporary publish directory. I have almost no control over that. I found a solution to redirecting where the temporary directory is, but it involved transformations and I wasn’t sure how to implement the solution. Read Here.

The blue part is a service reference is that I am using and the whole lot of that is auto generated. I have, again, almost no control over that. Can I shorten the names? Yes? However it would make the meaning very unclear and I shouldn’t have to make my source code unclear so that I can be within a limitation that Microsoft set 10 years ago and they never fixed.

Where do I complain about this too?
This is the Declined Request
https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2156195-fix-260-character-file-name-length-limitation

This is the New Request
http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/4954037-fix-260-character-file-name-length-limitation

Playing Devil’s Advocate
I totally understand why Microsoft isn’t tending to this problem, the quazi-bullshit answer provided says it all: We are too busy and do not care enough about your issue, as the number of people experiencing this issue on a daily is very small in comparison to literally the rest of the world. So yeah I totally understand that – but wow… Hard coded limitations. This is a very good example of WHY YOU DON’T USE MAGIC NUMBERS!!!!!!

Conclusion and Reasoning
This is why I always warn people NOT TO NEST THEIR PROJECTS TOO DEEPLY. When you are linked up to source control – make absolutely sure that you use a shallow structure. DO NOT put your root folder in your “My Documents” folder, do not use the default path that is provided by Visual Studio. Just use a very simple structure such as:
Drive:DevTFSServerName…. this is your root!

Example:
C:DevTfsServer.AD.Local

2 Replies to “File Name, File Path or Full File Path name is too long”

    1. No problem. I keep hearing that and I have been meaning to check it out. Just at the time when I was trying to publish my web application I had never seen this error before so it took me for a ride and I thought there was a work around.

      I will look up the Long Path Tool, but in a few words how would that help me during a publish?

Leave a Reply

Your email address will not be published. Required fields are marked *