17

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);
Community
  • 1
  • 1
Michael Fender
  • 551
  • 2
  • 6
  • 15

1 Answers1

16

What about RefreshSection?

ConfigurationManager.RefreshSection("appSettings");
wageoghe
  • 27,390
  • 13
  • 88
  • 116