C#读写config配置文件
2021-07-10 23:08
标签:return get 配置文件 读写 tin set ring ret level C#读写config配置文件 标签:return get 配置文件 读写 tin set ring ret level 原文地址:https://www.cnblogs.com/xslwm/p/9673969.htmlclass Config
{
static Configuration _config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
private Config()
{
}
static public void AddAppSetting(string key, string value)
{
_config.AppSettings.Settings.Add(key, value);
_config.Save();
}
static public void SetAppSetting(string key, string value)
{
_config.AppSettings.Settings.Remove(key);
_config.AppSettings.Settings.Add(key, value);
_config.Save();
}
static public string GetAppSetting(string key)
{
return _config.AppSettings.Settings[key].Value;
}
static public void DelAppSetting(string key)
{
_config.AppSettings.Settings.Remove(key);
_config.Save();
}
}