c# 读取confgi文件
引用命名空间
using System.Configuration;
Winform—C#读写config配置文件
1、获取 节点appSettings内容
ConfigurationManager.AppSettings["CraneNo"]
2、获取数据库连接
ConfigurationManager.ConnectionStrings["FGCZ"].ConnectionString
多个配置文件读取
var map = new ExeConfigurationFileMap
{
ExeConfigFilename = AppDomain.CurrentDomain.BaseDirectory + "\\meter.config"
};
var config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
sMeterCODE = config.AppSettings.Settings["metercode"].Value;