Modify app.config in C# application
I am newbie in C# application that uses the app.config file to set up various things: for example, the path to store the files on the workstation on which the application is installed.
Can we, after installing the program manually modify app.config to change the values associated with keys? For now the application does not include my changes ...
Apparently this is not the right way to go ... So how do handle this sort of thing?
Re: Modify app.config in C# application
Well you can add/modify keys or values in your file app.config (it is for that), but it still requires that the application is coded to reflect these changes. If you added to such a tag <user name="foo" password="password"/>, we must know that your application is likely to have a <user> with attributes in the app. config
Re: Modify app.config in C# application
thank you, but still how ...
1) on my dev platform, my application gets the value of a variable <add key="path" value="c:\thing"> stored in app.config with ConfigurationManager.AppSettings["path"].OK.
2) on a pc user who installs the application, the value of "path" should be changed to "c:\widget".
The thing is, I manually alter the app.config placed in the directory where the application is installed, and that it completely ignores the new value of "c:\widget".
In fact, I try just to have a good old file .ini ...
Re: Modify app.config in C# application
In the directory where you installed your Application, the app. config must be under the name "yourApplic.exe.config". it is not called "app.config" once compiled.
Sorry I had forgotten this detail
Re: Modify app.config in C# application
Quote:
Originally Posted by
Sean J
I am newbie in C# application that uses the app.config file to set up various things: for example, the path to store the files on the workstation on which the application is installed.
Can we, after installing the program manually modify app.config to change the values associated with keys? For now the application does not include my changes ...
Apparently this is not the right way to go ... So how do handle this sort of thing?
It depends that in which type of project you added your config file.
If the app.config file was originally created in a dll project , you wont be able to edit the values(or you cannot use it , even if you edited).
Instead if the app.config file is in exe project , (\MyProject\bin\Debug\myproject.exe.config) , then it is possible to edit the values , and use the new values at runtime.
Re: Modify app.config in C# application
Hi, after a lot of struggling I found a way to change the settings in a dll without recompiling and wrote a post about it, if you are having trouble changing them in the main app I also added a Demo that may help you.
http://moebiusit.com/blog/pabloroman...-re-compiling/