public static bool SaveProjectToFile(bool InNewFile) { try { win32.SaveFileDialog saveFileDialog = new win32.SaveFileDialog(); saveFileDialog.Filter = "XML file (*.xml)|*.xml"; if (FilePath == "" || FilePath == null || InNewFile) { if (saveFileDialog.ShowDialog() == true) { FilePath = saveFileDialog.FileName; } else { return(false); } } XmlTextWriter textWritter = new XmlTextWriter(FilePath, Encoding.UTF8); textWritter.WriteStartDocument(); textWritter.WriteStartElement("Project"); textWritter.Close(); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(FilePath); XmlElement xmlRoot = xmlDocument.DocumentElement; XmlElement xmlSite = BuildingSite.SaveToXMLNode(xmlDocument); xmlRoot.AppendChild(xmlSite); xmlDocument.Save(FilePath); IsDataChanged = false; return(true); } catch (Exception ex) { MessageBox.Show("Ошибка сохранения: " + ex.Message); return(false); } }