C#读取web.config文件信息
web.config
<?xml version="1.0"?>
<!--
有关如何配置 ASP.NET 应用程序的详细信息,请访问
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<appSettings>
<add key="name" value="name1"/>
</appSettings>
</configuration>
C#读取
string name = System.Web.Configuration.WebConfigurationManager.AppSettings["name"];
C#设置
System.Web.Configuration.WebConfigurationManager.AppSettings.Set("name", "name2");

本文介绍了如何使用C#来读取和设置web.config文件中的配置信息。通过`System.Web.Configuration.WebConfigurationManager`类的`AppSettings`属性,可以方便地获取或修改配置项,例如读取键为name的值以及设置新的值。
221

被折叠的 条评论
为什么被折叠?



