Change value to App.config file

0

I am trying to change the value of the App.config file and it does not save anything to me, I do not get any errors when saving, and when it rerun the program continues with the same value.

var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var settings = configFile.AppSettings.Settings;

Console.WriteLine(settings["id_shops"].Value = "50");

configFile.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name);
    
asked by Jose Yeste 27.10.2017 в 10:57
source

1 answer

3

The problem is that the file you are modifying is that of the bin / Debug folder. It is normal that you do not save the changes because when compiling, replace this file with the original and overwrite it.

To solve this, you only have to make the changes in the original file, located in the root of the project and when compiling you will see that you have saved the changes.

    
answered by 27.10.2017 / 12:47
source