物性更改2
一些已知的更改
This commit is contained in:
@@ -16,7 +16,8 @@ namespace CapMachine.Core
|
||||
/// <param name="key"></param>
|
||||
public static string GetValue(string key)
|
||||
{
|
||||
return ConfigurationManager.AppSettings[key].ToString().Trim();
|
||||
var value = ConfigurationManager.AppSettings[key];
|
||||
return (value ?? string.Empty).Trim();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -31,7 +32,14 @@ namespace CapMachine.Core
|
||||
//cfa.Save();
|
||||
|
||||
Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
configuration.AppSettings.Settings[key].Value = value;
|
||||
if (configuration.AppSettings.Settings[key] == null)
|
||||
{
|
||||
configuration.AppSettings.Settings.Add(key, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
configuration.AppSettings.Settings[key].Value = value;
|
||||
}
|
||||
configuration.Save();
|
||||
ConfigurationManager.RefreshSection("appSettings");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user