So far manipulating XML (reading/writing) has been a bit more challenging than standard windows. I am trying to open the config file for editing, make changes and then save the file again to disk.
I can open the file as a StorageFile
, convert it to XDocument
but I am having trouble saving the XDocument
to disk, can anyone offer code that would do the trick? Currently I have
StorageFile file = await installedLocation.GetFileAsync(fileNameAndPath);
var data = await FileIO.ReadTextAsync(file);
string actualXML = data.ToString();
XDocument doc = XDocument.Parse(actualXML);
// do work
//save
MemoryStream ms = new MemoryStream();
XmlWriter w = XmlWriter.Create(ms);
doc.WriteTo(w);