|
@@ -124,6 +124,31 @@ namespace CommonLang.Xml
|
|
|
return doc;
|
|
|
}
|
|
|
|
|
|
+ static public bool SaveXML(String path, XmlDocument doc, out string errMessage)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write))
|
|
|
+ {
|
|
|
+ XmlWriterSettings settings = new XmlWriterSettings();
|
|
|
+ settings.Indent = true;
|
|
|
+ settings.Encoding = Encoding.UTF8;
|
|
|
+ using (XmlWriter xml = XmlWriter.Create(fs, settings))
|
|
|
+ {
|
|
|
+ doc.Save(xml);
|
|
|
+ xml.Flush();
|
|
|
+ }
|
|
|
+ errMessage = null;
|
|
|
+ fs.Close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception e)
|
|
|
+ {
|
|
|
+ errMessage = e.Message;
|
|
|
+ }
|
|
|
+ return errMessage == null;
|
|
|
+ }
|
|
|
+
|
|
|
static public void SaveXML(Stream output, XmlDocument doc, bool autoDisposeStream)
|
|
|
{
|
|
|
try
|