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
URI formats are not supported in c#
提问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:
这是错误:
回答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:
您可以尝试使用此解决方案:
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;