Web.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings configSource="Config\app.config"></appSettings>
</configuration>
Ps. configSource="Config\app.config",此处一定要使用反斜杠“\”;
Config\app.config file:
<?xml version="1.0"?>
<appSettings>
<add key="Version" value="1.0.0" />
<add key="Country" value="China"/>
</appSettings>
读取配置文件值:
string value = ConfigurationManager.AppSettings["Country"].ToString();
原文地址:https://www.cnblogs.com/by-lhc/p/8797054.html
时间: 2024-11-05 12:11:37