Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing App Settings during run time [duplicate]

Tags:

c#

So I was looking at the solution here to figure out how to do it. And, it works for when I run my project multiple times. However, from my understanding, the save only occurs when the project closes. What I would like to do is to save it when I need to during my code, so that during the same run time, I can accessed the previously saved files. Does anybody know how to approach this problem?

This is what I'm using to save my app settings at run time:

Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["CurrentPromoId"].Value = promo_id.ToString();
config.AppSettings.Settings["Date"].Value = DateTime.Today.ToString("yyyyMMdd");
config.Save(ConfigurationSaveMode.Modified, true);
like image 752
Michael Fender Avatar asked Apr 04 '13 19:04

Michael Fender


1 Answers

What about RefreshSection?

ConfigurationManager.RefreshSection("appSettings");
like image 116
wageoghe Avatar answered Oct 30 '22 01:10

wageoghe