c# - How to save a file by using serialize xml -
im trying save file datagrid using button dont know how make saving , user can choose save. having problems on code.
private void button_click_4(object sender, routedeventargs e) { var path = @"c:\\users\\tiago\\documents\\teste\\save.xml"; if (serializableobject == null) { return; } try { xmldocument xmldocument = new xmldocument(); xmlserializer serializer = new xmlserializer(serializableobject.gettype()); using (memorystream stream = new memorystream()) { serializer.serialize(stream, serializableobject); stream.position = 0; xmldocument.load(stream); xmldocument.save(path); stream.close(); } } catch (exception ex) { } }
this got now.
if want allow user choose location , name of file, there savefiledialog option available you.
here of links can accomplish this:
msdn link_1
msdn link_2
link_3
Comments
Post a Comment