ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = filePath;
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
AppSettingsSection appSettings = (AppSettingsSection)config.GetSection("appSettings");
KeyValueConfigurationCollection keyValues = appSettings.Settings;

Dictionary<string, string> items = new Dictionary<string, string>();
 foreach (string key in keyValues.AllKeys)
{
       items.Add(key, keyValues[key].Value);
}

return items;

 

注意 :  不要使用  var 对上面程序进行 变量声明

相关文章:

  • 2022-12-23
  • 2021-05-17
  • 2021-07-18
  • 2022-01-20
  • 2022-12-23
  • 2021-07-22
猜你喜欢
  • 2022-02-01
  • 2021-09-12
  • 2019-01-16
  • 2021-09-03
  • 2022-02-09
  • 2022-12-23
相关资源
相似解决方案