Beispiel #1
0
        /// <summary>
        /// Saves the settings to the specified file.
        /// </summary>
        public bool Save(string fileName, out string errMsg)
        {
            try
            {
                XmlDocument    xmlDoc  = new XmlDocument();
                XmlDeclaration xmlDecl = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);
                xmlDoc.AppendChild(xmlDecl);

                XmlElement rootElem = xmlDoc.CreateElement("ScadaAdminConfig");
                xmlDoc.AppendChild(rootElem);

                PathOptions.SaveToXml(rootElem.AppendElem("PathOptions"));
                ChannelOptions.SaveToXml(rootElem.AppendElem("ChannelOptions"));

                XmlElement fileAssociationsElem = rootElem.AppendElem("FileAssociations");
                foreach (KeyValuePair <string, string> pair in FileAssociations)
                {
                    XmlElement associationElem = fileAssociationsElem.AppendElem("Association");
                    associationElem.SetAttribute("ext", pair.Key);
                    associationElem.SetAttribute("path", pair.Value);
                }

                xmlDoc.Save(fileName);
                errMsg = "";
                return(true);
            }
            catch (Exception ex)
            {
                errMsg = CommonPhrases.SaveAppSettingsError + ": " + ex.Message;
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Saves the settings to the specified file.
        /// </summary>
        public bool Save(string fileName, out string errMsg)
        {
            try
            {
                XmlDocument    xmlDoc  = new XmlDocument();
                XmlDeclaration xmlDecl = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);
                xmlDoc.AppendChild(xmlDecl);

                XmlElement rootElem = xmlDoc.CreateElement("ScadaAdminConfig");
                xmlDoc.AppendChild(rootElem);

                PathOptions.SaveToXml(rootElem.AppendElem("PathOptions"));
                ChannelOptions.SaveToXml(rootElem.AppendElem("ChannelOptions"));

                xmlDoc.Save(fileName);
                errMsg = "";
                return(true);
            }
            catch (Exception ex)
            {
                errMsg = CommonPhrases.SaveAppSettingsError + ": " + ex.Message;
                return(false);
            }
        }