亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

使用linq to xml修改app.config示例(linq讀取xml)

 更新時間:2014年02月25日 10:53:45   作者:  
這篇文章主要介紹了使用linq to xml修改app.config示例,需要的朋友可以參考下

復(fù)制代碼 代碼如下:

Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); 
configuration.AppSettings.Settings["節(jié)點名稱"].Value ="0"; 
configuration.Save(ConfigurationSaveMode.Modified);  

復(fù)制代碼 代碼如下:

//獲取config路徑
   string path = System.Windows.Forms.Application.ExecutablePath + ".config";
   XDocument doc = XDocument.Load(path);
   //查找所有節(jié)點
   IEnumerable<XElement> element = doc.Element("configuration").Element("appSettings").Elements();
   //遍歷節(jié)點
   foreach (XElement item in element)
   {
       if (item.Attribute("key") != null && item.Attribute("key").Value == "節(jié)點名稱")
       {
           if (item.Attribute("value") != null)
           {
  item.Attribute("value").SetValue(DateTime.Now.ToString("d"));
           }
       }
   }
   //保存
   doc.Save(path);

相關(guān)文章

最新評論