C#修改app.config配置文件信息2007-03-06 14:10//更新app.config的函数private   void   UpdateConfig(string   Xvalue)
{   
    XmlDocument   doc   =   new   XmlDocument();   
    doc.Load(Application.ExecutablePath+".config");   
    XmlNode   node   =   doc.SelectSingleNode(@"//add[@key='ServerName']");   
    XmlElement   ele   =   (XmlElement)node;   
    ele.SetAttribute("value",Xvalue);   
    doc.Save(Application.ExecutablePath+".config");     
}   //配置文件的源文件  <?xml   version="1.0"   encoding="utf-8"   ?>   
  <configuration>   
  <appSettings>   
  <add   key="ServerName"   value=""/>   
  </appSettings>   
  </configuration>   
 
原文来自http://hi.baidu.com/i7521/blog/item/d5e785457268203f869473a1.html

解决方案 »

  1.   


            //给你个修改xml节点的例子
            Dim doc As New System.Xml.XmlDocument
            doc.Load("E:\工程\读取xml\book.XML")
            Dim st As Xml.XmlNodeList = doc.SelectSingleNode("bookstore").ChildNodes
            Dim gy As Xml.XmlNode
            Dim sg As Xml.XmlElement
            For Each gy In st
                sg = gy
                If sg.GetAttribute("genre") = "GY" Then
                    sg.SetAttribute("genre", "GY")
                    Dim gy1 As Xml.XmlNodeList = sg.ChildNodes
                    Dim st1 As Xml.XmlNode
                    Dim gy2 As Xml.XmlElement
                    For Each st1 In gy1
                        gy2 = st1
                        If gy2.Name = "作者" Then
                            gy2.InnerText = "st"
                            Exit For
                        End If
                    Next
                End If
            Next
            doc.Save("E:\工程\读取xml\book.XML")
            MsgBox("修改成功!", MsgBoxStyle.Information, "XML")
      

  2.   

    http://geekswithblogs.net/akraus1/articles/64871.aspxConfigurationManager
      

  3.   


    就这样.就是XML文件.别看他的后缀.config.文件.NET本身做了很多操作方面的封装,你直接当xml搞就是了.