简体   繁体   English

保存修改的XML- WP8 C#

[英]Saving Modified XML- WP8 C#

I've been trying to modify and save an xml dynamically. 我一直在尝试动态修改和保存xml。 i've tried to find some answers but i didnt manage to. 我试图找到一些答案,但我没有设法做到。 i Succeeded to modify and change the xml data, but i encounter a problem with saving. 我成功修改和更改了xml数据,但是保存时遇到了问题。 here is the code: 这是代码:

var resourceStreamInfo = Application.GetResourceStream(uri);
using (var stream = resourceStreamInfo.Stream)
{
     doc = XDocument.Load(stream);
     var Currencies = doc.Descendants("Currency");
     XElement root = Currencies.Where(b => b.Element("ID").Value.IndexOf(CurrencyID, StringComparison.CurrentCultureIgnoreCase) >= 0).First();
     root.SetElementValue("Rate", rate);

     doc.Save(stream);
}   

I understood that my stream is readonly, but what should I do? 我知道我的信息流是只读的,但是我该怎么办?

From Application.GetResourceStream I guess your are reading a file from your project bundle. Application.GetResourceStream我猜您正在从您的项目捆绑中读取文件。 You cannot modify it. 您不能修改它。 You need to save the modified file to isolated storage 您需要将修改后的文件保存到隔离存储中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM