Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP Windows NET
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("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&reg-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 15-Feb-12 4:21am
kms_310
Edited 15-Feb-12 4:46am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
You can use a tinyurl service to shorten the URL.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hi,
You can use a tinyurl service to shorten the URL.
  Permalink  
Comments
Michael dg at 15-Feb-12 10:40am
   
how about using POST instead of GET method?
kms_ at 16-Feb-12 2:26am
   
sorry.. you have to be more specific.. can you give me an example..
but I decided to give the tinyURL a shot, seeing that I have no other alternative
kms_ at 16-Feb-12 3:50am
   
Thank you very much "Michael dg".. it's a little risky doing it with a tinyurl, but the good new is that it worked.. Lets hope the service is up and running 24/7 :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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!
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 8

Hello,

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


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

thank you
  Permalink  
Comments
AnvilRanger at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,474
1 OriginalGriff 6,258
2 Peter Leow 2,534
3 Abhinav S 2,274
4 Maciej Los 2,268


Advertise | Privacy | Mobile
Web03 | 2.8.150414.1 | Last Updated 16 Feb 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100