.net 2.0 配置文件
2.0用WebConfigurationManager,ConfigurationManager替换了原先的ConfigurationSettings
<appSettings>
<add key="UploadFilePath" value="~/Upload"></add>
</appSettings>
这段,注意 add 之后使用了key,而不是原来的name!
下面这段代码读取这个字段
Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
AppSettingsSection appSection = (AppSettingsSection)config.GetSection("appSettings");
string sPath =Server.MapPath(appSection.Settings["UploadFilePath"].Value.ToString());
如果是name会报错
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
下面这段代码读取这个字段
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)