Save edited XML Document to any location?
c#, c#-4.0, wpf, xml
Solution
see the code below; be aware that the UAC if the user select some system folder.
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Xml (*.xml)|*.xml";
if (saveFileDialog.ShowDialog().Value)
{
doc.Save(saveFileDialog.FileName);
}
Problem
In the below C# WPF code snippet, I want to load an XML document, edit the document, and save the output to a user designated location. I can use the `XmlDocument.Save` method to save to a pre-defined location, but how can I allow the user to save to any location like when choosing 'SaveAs'? ``` XmlDocument doc = new XmlDocument(); doc.Load(@"C:\OriginalFile.xml"); doc.Save("File.xml"); ```