Click here to Skip to main content
15,885,366 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:
C#
<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
C#
string encoded = Server.UrlEncode("https://test.httpapi.com/api/domains/register.xml?auth-userid=0&auth-password=password&domain-name=domain.asia&years=1&ns=ns1.domain.com&ns=ns2.domain.com&customer-id=0®-contact-id=0&admin-contact-id=0&tech-contact-id=0&billing-contact-id=0&invoice-option=KeepInvoice&protect-privacy=true");
try
{
    XmlDocument doc = new XmlDocument();
    doc.Load(encoded);
    ....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..
Posted
Updated 12-Sep-18 21:56pm
v3

Hi,
You can use a tinyurl service to shorten the URL.
 
Share this answer
 
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: http://msdn.microsoft.com/en-us/library/875kz807.aspx[^]

Good luck!
 
Share this answer
 
Hello,

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
 
Share this answer
 
Comments
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.
Ana fletcher 4 days ago    
hey, has anyone used Longpath tool? How is it?

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