Add datas from WP8 to a XML file



I am trying to add the datas obtained from my list picker into an xml. I could not figure out where the mistake is since I am new to this.


C# code



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();
}


I have my xml file on the same project and the code likes



<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<Noofppl>
<ppl>
<Adults>

</Adults>
<children>

</children>
</ppl>
</Noofppl>

No comments:

Post a Comment