"refreshing" application configuration settings
-
Hi, I'm trying to update an app.config file for an application. After I update the config file how do I tell the application to "refresh" the settings it read from the config originally? example: string val = ConfigurationSettings.AppSettings["companyName"]; // val = "My Co" use my own routine to write the setting: SetValue("companyName", "YourCo"); string val2 = ConfigurationSettings.AppSettings["companyName"]; // val2 = "My Co", but I want it to be "YourCo" It's only after I close the application and restart it that I pick up the "YourCo" value. Thanks for any suggestions, Trevor B
-
Hi, I'm trying to update an app.config file for an application. After I update the config file how do I tell the application to "refresh" the settings it read from the config originally? example: string val = ConfigurationSettings.AppSettings["companyName"]; // val = "My Co" use my own routine to write the setting: SetValue("companyName", "YourCo"); string val2 = ConfigurationSettings.AppSettings["companyName"]; // val2 = "My Co", but I want it to be "YourCo" It's only after I close the application and restart it that I pick up the "YourCo" value. Thanks for any suggestions, Trevor B
-
Hi, I'm trying to update an app.config file for an application. After I update the config file how do I tell the application to "refresh" the settings it read from the config originally? example: string val = ConfigurationSettings.AppSettings["companyName"]; // val = "My Co" use my own routine to write the setting: SetValue("companyName", "YourCo"); string val2 = ConfigurationSettings.AppSettings["companyName"]; // val2 = "My Co", but I want it to be "YourCo" It's only after I close the application and restart it that I pick up the "YourCo" value. Thanks for any suggestions, Trevor B
You could add a Settings.settings file to your application. When you edit this file in VS you have to change the Scope to User. After that: DateTime _date = DateTime.Today; if (_date.Year > Properties.Settings.Default.MyDateOfSomething.Year) { Properties.Settings.Default.MyDateOfSomething = _date; } Properties.Settings.Default.Save(); Properties.Settings.Default.Upgrade();