<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings> 
    <add key="width" value="200" />
    <add key="height" value="100" />
  </appSettings> 
</configuration>如何修改width和height的值?

解决方案 »

  1.   

    先找到該節點,修改其value,然後保存
    msdn上有samples
      

  2.   

    string fileName = "";
    if (openFileDialog1.ShowDialog() ==DialogResult.OK)
    {
    fileName = openFileDialog1.FileName ;

    }
    XmlDocument myXmlDocument = new XmlDocument();
    myXmlDocument.Load(fileName);
    XmlNode rootNode = myXmlDocument.DocumentElement;
    //以下为修改值
       rootNode.ChildNodes[0].ChildNodes[0].Attributes["value"].Value = 400;
        rootNode.ChildNodes[0].ChildNodes[1].Attributes["value"].Value = 200;  
        myXmlDocument.save(Application.StartupPath+@"\updateNewBook.xml");