读当前项目配置文件
string heightWeightFlag = ConfigurationSettings.AppSettings["heightWeightFlag"];
读非当前项目配置文件
string path = System.AppDomain.CurrentDomain.BaseDirectory;
if (File.Exists(path + "../ZillionReport.exe.config"))//判断是否存在
{
ExeConfigurationFileMap newmap = new ExeConfigurationFileMap();
newmap.ExeConfigFilename = @"../ZillionReport.exe.config";
Configuration newconfig = ConfigurationManager.OpenMappedExeConfiguration(newmap, ConfigurationUserLevel.None);
AppSettingsSection newappSection = newconfig.AppSettings;
var newappSettings = newappSection.Settings;
if (newappSettings.Count>0)
{
foreach (var key in newappSettings.AllKeys)
{
Console.WriteLine("Key: {0} Value: {1}", key, newappSettings[key]);
}
}
}
Configuration config = Configur