Im trying to save a file from a DataGrid using a button for it but i dont know how to make it saving that and the user can choose where to save. Also having some problems on the 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 is what i got for now.