Net dll add-in which is hosted in an exe provided by the app which I have no control over) so I was hoping to save a copy of the file and replace the config in the exe with the modified version at runtime.
Updating app config c
Modified); So the first time when the entry doesnt exist yet, it would simply create it, otherwise it would modify the existing entry. Is it in the Debug folder or in C:\Documents and Settings\USERNAME\Local Settings\Application Data folder? Configuration Section, Configuration Element and Configuration Element Collection require you to derive custom classes and implement custom Configuration Property properties. Here is an example of reading and writing to web.config: using System. Open Web Configuration("/"); string old Value = config.
2) Where am I expecting the usersettings for App settings to be saved again? The best way to test this is to build your application and then navigate to the output directory and launch your executable from there. It is much easier to read AND write with (Web)Configuration Manager. Configuration; Configuration config = Web Configuration Manager.
Save(); One major point to note with the above is that if you are running this from the debugger (within Visual Studio) then the app.config file will be overwritten each time you build. it use indtead "Name Application"exe so the name of the config file is "Name Application"exe.config and not "Name Application"config and after the application close - it return to the back app.config so if you check the wrong file or you check on the wrong time you will see that nothing changed.
I think the problem is that in the debug visual studio don't use the normal exe Name.
None); Net Section Group net Section Group = config.
Save As(@"C:\Program Data\test.config", Configuration Save Mode.
Set Data("APP_CONFIG_FILE", @"C:\Program Data\test.config"); I did not understand from your question if you don't have access to the app.config file because of your own design implementation or you just weren't able to save the config file, so here is a piece of code that allows you to modify and save app Settings section in the config file at runtime: Configuration config = Configuration Manager. None); Key Value Configuration Collection settings = config. Settings; // update Save Before Exit settings[-keyname-].
Modified); //relaod the section you modified Configuration Manager.
It might sound too trival to ask and I do the same thing as suggested in articles, yet it doesn't work as expected. I would like to save the usersettings per App Settings.