Reputation: 8962
I want to save xml file, but I get error messages. Regarding the documentation I should use a class in the Windows.Storage, but I don't know which class I should use and how to use it.
string filename;
XDocument doc = XDocument.Load(filename);
...
doc.Save(filename);
Error: Argument 1: cannot convert from 'string' to 'System.IO.Stream'
Error: The best overloaded method match for 'System.Xml.Linq.XDocument.Save(System.Xml.XmlWriter)' has some invalid arguments
Upvotes: 0
Views: 1388
Reputation: 8962
StorageFile file = await StorageFile.GetFileFromPathAsync(filename);
using (Stream fileStream = await file.OpenStreamForWriteAsync())
{
doc.Save(fileStream);
}
Upvotes: 1