保存到 xml 文档
我正在“尝试”弄清楚如何创建Windows Phone 7 应用程序,并且我想使用以下功能更新/保存 xml 文件:
XDocument xmlDoc = XDocument.Load("myApp.xml");
xmlDoc.Element("ocd").Add(new XElement("vDetails", new XElement("itemName", this.tb_Name.Text),
new XElement("Date", System.DateTime.Now.ToString()), new XElement("itemValue", "")));
xmlDoc.Save("data.xml");
但是 xmlDoc.保存行给出错误:“System.Xml.Linq.XDocument.Save(System.Xml.XmlWriter) 的最佳重载方法匹配有一些无效参数。
我需要做什么来纠正这个问题?
I am "trying" to figure out how to create a Windows Phone 7 application and I would like to update/save an xml file with the following function:
XDocument xmlDoc = XDocument.Load("myApp.xml");
xmlDoc.Element("ocd").Add(new XElement("vDetails", new XElement("itemName", this.tb_Name.Text),
new XElement("Date", System.DateTime.Now.ToString()), new XElement("itemValue", "")));
xmlDoc.Save("data.xml");
However the xmlDoc.Save line is giving an error: The best overloaded method match for "System.Xml.Linq.XDocument.Save(System.Xml.XmlWriter) has some invalid arguments.
What do I need to do to correct this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要保存到隔离存储(或其他一些地方)。获取应用程序的独立存储,打开文件流,然后保存到流中:
You need to save to isolated storage (or a few other places). Get the isolated storage for your application, open a stream to a file, and save to the stream:
Windows Phone 开发人员博客深入讨论了应用程序执行模型。
我认为区分应用程序“关闭”和应用程序被逻辑删除很重要。
应用程序执行模型
至于测试,一个想法可能是重构代码并添加记录各种事件点,例如关闭或被逻辑删除等。
The Windows Phone developer blog goes talks application execution model in great depth.
I think it is important to distinguish between application 'closing' and an application being tombstoned.
Application Execution Model
As for testing, an idea may be to refactor the code and add logging for various event points like closing or being tombstoned etc.