C # - Write in app.config and keep the changes

0

I can not modify a key defined in my configuration file at the runtime (app.config) and that the change is saved when I re-run my application next time.

If I check the values at runtime I see that they actually change, but when I check the configuration file I do not see the change.

        Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
        config.AppSettings.Settings["MiClave"].Value = "NuevoValor";
        config.Save(ConfigurationSaveMode.Modified);

        ConfigurationManager.RefreshSection("appSettings");

I can not understand what I'm missing.

    
asked by Willy616 12.04.2017 в 15:47
source

1 answer

3

The configurations in an executable are not stored in app.config . Look in the file TuAplicacion.exe.config , there you should see the changes

    
answered by 12.04.2017 / 16:05
source