C# 不支持 URI 格式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19761944/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 15:48:32  来源:igfitidea点击:

URI formats are not supported in c#

c#asp.netpath

提问by raje

I am trying to insert my data in to xml file. the xml file location path: http://AutoCompleteInGridView%20new1/Design/Pro/pricelist.xml. when inserting my data i got error URI formats are not supported. It shows argument exception was unhandled.I want to save my xml file in server system.these url belongs to ServerPath location. can anyone give me a suggestion or links to solve these problem.

我正在尝试将我的数据插入到 xml 文件中。xml 文件位置路径:http://AutoCompleteInGridView%20new1/Design/Pro/pricelist.xml. 插入我的数据时出现错误URI formats are not supported。它显示参数异常未处理。我想将我的 xml 文件保存在server system.these url 中,属于 ServerPath 位置。谁能给我一个建议或链接来解决这些问题。

here is the error:

这是错误:

enter image description here

在此处输入图片说明

回答by raje

Use this sample:

使用此示例:

                string uriPath = "YourAddress/pricelist.xml";
                string  localPath = new Uri(uriPath).LocalPath;

回答by Nico Leguizamon

you could try with this solution:

您可以尝试使用此解决方案:

http://social.msdn.microsoft.com/Forums/en-US/eccd585a-ac2b-4700-aa28-abb4802cd3a5/uri-formats-are-not-supported-error-with-xmlsave?forum=xmlandnetfx

http://social.msdn.microsoft.com/Forums/en-US/eccd585a-ac2b-4700-aa28-abb4802cd3a5/uri-formats-are-not-supported-error-with-xmlsave?forum=xmlandnetfx

Basically, use

基本上,使用

doc.Save(Server.MapPath("~/EEPPriceList/Products.xml"))

doc.Save(Server.MapPath("~/EEPPriceList/Products.xml"))

回答by Sorav Nayyar

Try like this:

像这样尝试:

string SavePathUrl = ConfigurationManager.AppSettings["SavePathUrl"];
string strFileName = DateTime.Now.ToString("dd-mmm-yyyy-hh-mm-ss-ffffff") + "^" + fileName;
File.WriteAllBytes(new Uri(SavePathUrl).AbsoluteUri + strFileName, Convert.FromBase64String(base64String));
return strFileName;