Skip to content

Instantly share code, notes, and snippets.

@glebov21
Last active May 17, 2021 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glebov21/8696693b509347a94e9911263f65a30e to your computer and use it in GitHub Desktop.
Save glebov21/8696693b509347a94e9911263f65a30e to your computer and use it in GitHub Desktop.
AppSettings read write
public static string GetSettings(string key)
{
return ConfigurationManager.AppSettings[key] ?? "";
}
public static void SetSetting(string key, string value)
{
Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
configuration.AppSettings.Settings[key].Value = value;
configuration.Save();
ConfigurationManager.RefreshSection("appSettings");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment