Changing App Settings during run time

c#

Solution

What about RefreshSection?

ConfigurationManager.RefreshSection("appSettings");

Problem

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); ```

Original source

Related problems