Beispiel #1
0
 //读取配置
 private static string ReadHostConfig(string key)
 {
     try
     {
         Configuration config = ConfigurationManager.OpenExeConfiguration(ExecutablePath);
         KeyValueConfigurationCollection appSettings = config.AppSettings.Settings;
         KeyValueConfigurationElement    add         = appSettings.Cast <KeyValueConfigurationElement>().FirstOrDefault(element => string.Equals(element.Key, key, StringComparison.OrdinalIgnoreCase));
         return(add == null ? null : add.Value);
     }
     catch
     {
         return(null);
     }
 }