使用C#實(shí)現(xiàn)讀取系統(tǒng)配置文件的代碼實(shí)例講解
更新時(shí)間:2015年12月27日 16:56:12 作者:SmartMZ
這篇文章主要介紹了使用C#實(shí)現(xiàn)讀取系統(tǒng)配置文件的代碼實(shí)例,使用到了ConfigurationManager類,需要的朋友可以參考下
需要添加引用,System.Configuration;
寫系統(tǒng)配置文件:
Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); if (addrService != "") { cfa.AppSettings.Settings["WebServiceUrl"].Value = addrService; } if (setLogin != "") { cfa.AppSettings.Settings["LoginServerUrl"].Value = setLogin; } if (mapPath != "") { cfa.AppSettings.Settings["InitMapPath"].Value = mapPath; } cfa.Save(ConfigurationSaveMode.Modified); //重新加載配置文件 ConfigurationManager.RefreshSection("appSettings");
讀:
<pre name="code" class="csharp"> string value = ConfigurationSettings.AppSettings["InitMapPath"];</pre> <pre></pre> <p></p> <pre></pre> <br> <br> <p></p> <p><br> </p>
相關(guān)文章
c#實(shí)現(xiàn)把漢字轉(zhuǎn)為帶田字格背景的jpg圖片
這篇文章主要介紹了c#實(shí)現(xiàn)把漢字轉(zhuǎn)為帶田字格背景的jpg圖片示例,需要的朋友可以參考下2014-03-03C# WebService創(chuàng)建、發(fā)布、調(diào)用的實(shí)例講解
下面小編就為大家分享一篇C# WebService創(chuàng)建、發(fā)布、調(diào)用的實(shí)例講解,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2017-12-12C# DataTable.Select()根據(jù)條件篩選數(shù)據(jù)問題
這篇文章主要介紹了C# DataTable.Select()根據(jù)條件篩選數(shù)據(jù)問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-01-01C#靜態(tài)構(gòu)造函數(shù)用法實(shí)例分析
這篇文章主要介紹了C#靜態(tài)構(gòu)造函數(shù)用法,以實(shí)例形式較為詳細(xì)的分析了C#靜態(tài)構(gòu)造函數(shù)的用途、實(shí)現(xiàn)方法及使用技巧,需要的朋友可以參考下2015-06-06