Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7035357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:17:41+00:00 2026-05-28T01:17:41+00:00

I have an app.config like below, <configuration> <environment> <add key=security value=1/> — I want

  • 0

I have an app.config like below,

<configuration>
    <environment>
        <add key="security" value="1"/> -- I want to change this value to 3
    </environment>
</configuration>

I tried like below to get to environment section,

Configuration config = ConfigurationManager.OpenExeConfiguration(exePath);
var environment = config.GetSection("environment");

environment variable doesn’t give me enough options to get the child elements to modify the value. Could any one please help me out in this one.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:17:42+00:00Added an answer on May 28, 2026 at 1:17 am

    Use user scope settings!! NEVER EVER change the application configuration that way. Any value that is changed within the application should be a user setting.

    Usually, you access these settings through

    Properties.Settings.Default.MyConfigurationValue = ....;
    Properties.Settings.Default.Save();
    

    EDIT
    Sample for doing what I wrote in the comments. Create two user settings: FirstRun is a bool which is by default set to true. Environment is your value, by default set to 0.

    Then, for example in the Main function in Program.cs you’d do the following:

    if (Properties.Settings.Default.FirstRun)
    {
        Properties.Settings.Default.FirstRun = false;
        if (myConditionIsTrue)
            Properties.Settings.Default.Environment = 3;
        Properties.Settings.Default.Save();
    }
    

    Later in your application it is enough to use Properties.Settings.Default.Environment. That’s how the settings mechanism is intended to be used if you want to change configuration values from your application.

    Under Windows 2000, XP, 7 and the Windows Server branch you would not even have the rights to modify the app.config in your Program Files folder, so don’t!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app.config file, with app settings like this: <appSettings> <add key=setting1 value=1/>
is it possible to have app.config file like this : <?xml version=1.0 encoding=utf-8 ?>
I'd like to be able to extend ConfigurationManager so that I have an app.config
I have app.config in m win application, and loggingConfiguration section (enterprise library 4.1). I
I have an app.config file inside my TestProject, but when I try to read
I have an app.Config that was created on the dev machine running Windows 7.
When I have one app.config in my main project I always have to duplicate
Is it possible to have two app.config files where one app.config serves as a
I have defined a config section in my app.config in the following way: <?xml
We have a custom section in my app.config file related to our IoC container

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.