How can I Serialize Object in windows 8 Metro App Development to xml file ?
I don’t know how to create stream , when I create streamWriter I get error on the file direction
StreamWriter nsw = new StreamWriter(@”C:\sample.xml”);
Error:
The best overload method match ‘system.io.streamwriter..streamwriter(system.io.stream) has some invalid arguments
this is the main code :
StorageFolder storageFolder = KnownFolders.DocumentsLibrary; StorageFile sampleFile = await storageFolder.CreateFileAsync("sample.xml"); XmlSerializer serializer = new XmlSerializer(ob.GetType()); serializer.Serialize(Stream stream,ob);
Here is an example that I use. The Serialize call (last line in your code) looks wrong.