日期:2014-05-17 浏览次数:20822 次
public static bool SetConfig(string key, string value)
{
try
{
Configuration conf = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (!conf.AppSettings.Settings.AllKeys.Contains(key))
conf.AppSettings.Settings.Add(key, value);
else
conf.AppSettings.Settings[key].Value = value;
conf.Save();
return true;
}
catch { return false; }
}