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?
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.
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: