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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -