/// <summary> /// +写配置文件 /// </summary> /// <param name="Path">配置文件的路径</param> /// <param name="nKey">配置文件中你要该的节点名称</param> /// <param name="nValue">修改的节点值</param> public static void UpdateConfig2(string Path,string NodePath,string Value) { XmlDocument xml = new XmlDocument(); xml.Load(Path); XmlNode node = xml.SelectSingleNode(NodePath); node.InnerText = Value; xml.Save(Path); }
/// <summary> /// 读取配置文件 /// </summary> /// <param name="Path">配置文件的路径</param> /// <param name="key">读取的XML文件中的键</param> /// <returns>返回该健得值</returns> public static string ReadConfig2(string Path,string xmlPath){ System.Xml.XmlDocument xml = new System.Xml.XmlDocument(); xml.Load(Path); XmlNode node = xml.SelectSingleNode("/Root/MultipleShop/key"); if(node!=null){ return node.InnerText; }else{ return ""; } }