使用C#实现读取系统配置文件的代码实例讲解
程序员文章站
2022-04-10 09:53:10
需要添加引用,system.configuration;
写系统配置文件:
configuration cfa = configurationman...
需要添加引用,system.configuration;
写系统配置文件:
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>