0

I am unable to save modification of ' app.config ' file.

Here is the code.

Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

config.AppSettings.Settings["MDI"].Value= "1";


config.Save( ConfigurationSaveMode.Full );
ConfigurationManager.RefreshSection("appSettings");


There is no issue of reading app.config file. I am reading proper values .But if changed it ,it is not updating the file.
And I have also changed order of RefreshSection() and Save() function but hopeless.

Can anyone help to resolve this issue?

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by PierlucSS
0

Writting into .config file is not a good idea.
The config files are intended to give administrators a way to configure
certain settings and not to persist settings.
They reside (normally) under program files folder thus only admin (if not
set otherwise) can edit them.

If you have settings that you need to persist consider storing them in
user-specific or app-specific area.

If changing the app.config, the application will need to restart or you will need to execute it from an Xml/XDocument in order to apply the change to your current "session"

Edited by PierlucSS: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.