Click here to Skip to main content
15,393,955 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
In my project I use http api which returns xml responce. The problem is that the http addresses have significant number of parameters and are too long. Thats whay I get this 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.

I tried in webconfig file to write:
<httpRuntime maxUrlLength="1000" relaxedUrlToFileSystemMapping="true"/>

Didn't work..
I tryed putting the long string into a uri but then visual studio tells about an error and wants a string.
Here's my code
string encoded = Server.UrlEncode("®-contact-id=0&admin-contact-id=0&tech-contact-id=0&billing-contact-id=0&invoice-option=KeepInvoice&protect-privacy=true");
    XmlDocument doc = new XmlDocument();
    ....other code to get the loaded xml data....

I need a way to work around this limitation for < 260 characters. The string I posted is only a demo, my string is even longer after I add all the variables. I did a lot of search for this problem and got nothing, even tryed the "\\?\" witch is a work around but not for a http path. Please help..
Updated 12-Sep-18 21:56pm

You can use a tinyurl service to shorten the URL.
As you already know it can't be longer than 248/260 characters and your url is 292 characters and therefor to long. That's windows... limited by licence...

More info on XmlDocument.Load here:[^]

Good luck!

you simply need to copy your project folder from your path to root directory (ex:-d:\abc\abc\xyz\YourProject to d:\YourProject )

Maximum file path length Error Solved.this trick work in my case.

thank you
AnvilRanger 19-Nov-14 7:45am
This question is well over 2 years old and has accepted answers, plus your solution has nothing to do with the actual question. A url was to long not a file path.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900