Results 1 to 6 of 6

Thread: Modify app.config in C# application

  1. #1
    Join Date
    Feb 2008
    Posts
    624

    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?

  2. #2
    Join Date
    May 2008
    Posts
    2,302

    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

  3. #3
    Join Date
    Feb 2008
    Posts
    624

    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 ...

  4. #4
    Join Date
    May 2008
    Posts
    2,302

    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

  5. #5
    Join Date
    May 2009
    Posts
    1

    Re: Modify app.config in C# application

    Quote Originally Posted by Sean J View Post
    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.

  6. #6
    Pablo Romano Guest

    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/

Similar Threads

  1. how to make application for changing/modify file permission
    By dinafrinsi in forum Software Development
    Replies: 1
    Last Post: 28-04-2012, 01:43 PM
  2. Replies: 8
    Last Post: 18-04-2011, 08:09 AM
  3. Replies: 5
    Last Post: 17-04-2011, 08:51 AM
  4. Difference between Web.Config and Machine.Config File
    By Adrina_g in forum Software Development
    Replies: 5
    Last Post: 23-01-2010, 01:44 PM
  5. How to do web.config for an application
    By Pandya in forum Software Development
    Replies: 3
    Last Post: 06-03-2009, 10:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •