Пример #1
0
 public static void UpdateConfig(string name, string nKey, string nValue)
 {
     if (XmlCOM.ReadConfig(name, nKey) != "")
     {
         XmlDocument xmlDocument = new XmlDocument();
         xmlDocument.Load(HttpContext.Current.Server.MapPath(name + ".config"));
         XmlNodeList elementsByTagName = xmlDocument.GetElementsByTagName(nKey);
         XmlNode     xmlNode           = elementsByTagName[0];
         xmlNode.InnerText = nValue;
         XmlTextWriter xmlTextWriter = new XmlTextWriter(new StreamWriter(HttpContext.Current.Server.MapPath(name + ".config")));
         xmlTextWriter.Formatting = Formatting.Indented;
         xmlDocument.WriteTo(xmlTextWriter);
         xmlTextWriter.Close();
     }
 }
Пример #2
0
        public static void UpdateConfig(string name, string nKey, string nValue)
        {
            if (!(XmlCOM.ReadConfig(name, nKey) != ""))
            {
                return;
            }
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(HttpContext.Current.Server.MapPath(name + ".config"));
            xmlDocument.GetElementsByTagName(nKey)[0].InnerText = nValue;
            XmlTextWriter xmlTextWriter = new XmlTextWriter((TextWriter) new StreamWriter(HttpContext.Current.Server.MapPath(name + ".config")));

            xmlTextWriter.Formatting = Formatting.Indented;
            xmlDocument.WriteTo((XmlWriter)xmlTextWriter);
            xmlTextWriter.Close();
        }