当前位置:首页 > 通信资讯 > 正文

c# 读取配置文件(c#配置文件详解)

需要添加引用,System.Configuration;
写系统配置文件:

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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");

读:

?
1 2 3 4 5 6 7 8 9 <pre name="code" class="csharp"> string value = ConfigurationSettings.AppSettings["InitMapPath"];</pre> <pre></pre> <p></p> <pre></pre> <br> <br> <p></p> <p><br> </p>
如果您对该产品感兴趣,请填写办理(客服微信:xiaoxiongyidong)

为您推荐:

发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。