标签:style blog http color os io ar 文件 2014
关键代码:
public static string GetAppSettingsValue(string key) { ConfigurationManager.RefreshSection("appSettings"); return ConfigurationManager.AppSettings[key] ?? string.Empty; } public static bool UpdateAppSettings(string key, string value) { var _config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); if (!_config.HasFile) { throw new ArgumentException("程序配置文件缺失!"); } KeyValueConfigurationElement _key = _config.AppSettings.Settings[key]; if (_key == null) _config.AppSettings.Settings.Add(key, value); else _config.AppSettings.Settings[key].Value = value; _config.Save(ConfigurationSaveMode.Modified); return true; }
希望有所帮助!
标签:style blog http color os io ar 文件 2014
原文地址:http://www.cnblogs.com/Yan-Zhiwei/p/3948729.html