雷火电竞-中国电竞赛事及体育赛事平台

歡迎來到入門教程網(wǎng)!

C#教程

當(dāng)前位置:主頁 > 軟件編程 > C#教程 >

使用C#實現(xiàn)讀取系統(tǒng)配置文件的代碼實例講解

來源:本站原創(chuàng)|時間:2020-01-10|欄目:C#教程|點擊:

需要添加引用,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>

  

上一篇:C#中用foreach語句遍歷數(shù)組及將數(shù)組作為參數(shù)的用法

欄    目:C#教程

下一篇:日常收集C#接口知識(知識全面)

本文標題:使用C#實現(xiàn)讀取系統(tǒng)配置文件的代碼實例講解

本文地址:http://www.jygsgssxh.com/a1/C_jiaocheng/6760.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時內(nèi)進行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有