Last active
May 17, 2021 14:08
-
-
Save glebov21/8696693b509347a94e9911263f65a30e to your computer and use it in GitHub Desktop.
AppSettings read write
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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