指定的路径,文件名或两者都太长 [英] The specified path, file name, or both are too long

查看:498
本文介绍了指定的路径,文件名或两者都太长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我使用http api返回xml响应。问题是http地址具有大量参数并且太长。多数民众赞成我收到此错误:

指定的路径,文件名或两者都太长。完全限定的文件名必须少于260个字符,目录名必须少于248个字符。



我在webconfig文件中尝试写:

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"/>





没有工作..

我尝试将长字符串放入uri但是然后visual studio告诉错误并想要一个字符串。

这是我的代码



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®-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....
}





我需要一种方法来解决这个限制的问题。 260个字符。我发布的字符串只是一个演示,我添加所有变量后,我的字符串甚至更长。我做了很多搜索这个问题但没有得到任何东西,甚至试过\\?\女巫是一个解决方法,但不是一个http路径。请帮助..



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..

推荐答案

您好,

您可以使用tinyurl服务来缩短网址。
Hi,
You can use a tinyurl service to shorten the URL.


正如您所知,它不能超过248/260个字符,而您的网址是292个字符,因此很长。那个窗户......受到许可限制......



关于 XmlDocument.Load 的更多信息: http://msdn.microsoft.com/en-us/library/875kz807.aspx [<一个href =http://msdn.microsoft.com/en-us/library/875kz807.aspxtarget =_ blanktitle =新窗口> ^ ]

<祝你好运!祝你好运!
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!


您好,



您只需要从路径中复制项目文件夹到根目录(例如:-d:\ abc \abc \ xyz \ YourProject到d:\ YourProject)





最大文件路径长度错误已解决。这个技巧在我的情况下工作。



谢谢
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


这篇关于指定的路径,文件名或两者都太长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆