更新App.config文件内容

来源:互联网 发布:unity3d 360度全景 编辑:程序博客网 时间:2024/05/22 20:51
private   void   UpdateConfig(string   Xvalue)  
  {  
   XmlDocument   doc   =   new   XmlDocument();  
   doc.Load(System.Windows.Forms.Application.StartupPath+"//MapInfo.xml");  
   XmlNode   node   =   doc.SelectSingleNode(@"//add[@key='MapPath']");  
   XmlElement   ele   =   (XmlElement)node;  
   ele.SetAttribute("value",Xvalue);  
   doc.Save(System.Windows.Forms.Application.StartupPath+"//MapInfo.xml");   
  }
  
  private   string   ReadConfig()  
  {  
   XmlDocument   doc   =   new   XmlDocument();  
   doc.Load(System.Windows.Forms.Application.StartupPath+"//MapInfo.xml");  
   XmlNode   node   =   doc.SelectSingleNode(@"//add[@key='MapPath']");  
   XmlElement   ele   =   (XmlElement)node;  
   string retVal=ele.GetAttribute("value");  
   return retVal;
  }