[英]Add datas from WP8 to a XML file
我正在尝试将从列表选择器中获取的数据添加到xml中。 我不知道错误在哪里因为我是新手。
C#代码
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
{
var isoFileStream = new IsolatedStorageFileStream(@"D:\Backup\task\Project\
Project\FinalDatas.xml", FileMode.OpenOrCreate, FileAccess.ReadWrite, store); // I get an exception here
var xDoc = XDocument.Load(isoFileStream);
isoFileStream.Close();
var contactsElement =
new XElement("Noofppl",
new XElement("ppl",
new XElement("Adults", ListAdults.SelectedItem.ToString()),
new XElement("children", ListChildren.SelectedItem.ToString())));
// IsolatedStorageFileStream location = new IsolatedStorageFileStream(ListAdults.SelectedItem.ToString() + ".item", System.IO.FileMode.Create, storage);
xDoc.Root.Add(contactsElement);
xDoc.Save(isoFileStream);
isoFileStream.Close();
}
我在同一个项目上有我的xml文件,代码也喜欢
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<Noofppl>
<ppl>
<Adults>
</Adults>
<children>
</children>
</ppl>
</Noofppl>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.