// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Configuration; namespace E { public class Program { public static bool GetSetting(string name) { return bool.Parse(ConfigurationManager.AppSettings[name]); } public static void SetSetting(string name, bool val) { Configuration cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); cfg.AppSettings.Settings[name].Value = val.ToString(); cfg.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("appSettings"); } public static void Main(string[] args) { Console.WriteLine(GetSetting("chkbox")); SetSetting("chkbox", true); Console.WriteLine(GetSetting("chkbox")); } } }