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

  • Home
  • SEARCH
  • 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 8802695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:09:00+00:00 2026-06-14T01:09:00+00:00

I am using .NET 4.0 and I would like to use the app.config file

  • 0

I am using .NET 4.0 and I would like to use the app.config file to store same parameter settings. I do the following. I use the Settings tab in the project properties to create my parameters.

This add the information in the app.config file like this:

<MyApp.Properties.Settings>
      <setting name="param1" serializeAs="String">
        <value>True</value>
      </setting>
<MyApp.Properties.Settings>

In my view model (in my code) I can access to the information in this way:

bool myBool = MyApp.Properties.Default.param1;

When I try to change the value in the config file, I try this:

Properties.Settings.Default.param1 = false;

But this causes an error, that param1 is read-only.

So how can I update my config file from my code?

  • 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-06-14T01:09:01+00:00Added an answer on June 14, 2026 at 1:09 am

    Well, I read the link of Hari Gillala, in which one user suggested to edit directly the app.config file, that is a xml file.

    So in project properties–>settings I create the parameters that I need. Then, to load a parameter in code I do the following:

    _myViewModelProperty = MyApp.Properties.Settings.Default.MyParam1;
    

    In this way, I can read easily the information of the config parameter. Is typed, so in disign time I can see if the asign is correct or not.

    To update de config file, I edit the app.config file with the xml libraries of .NET.

        System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
        xml.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
        System.Xml.XmlNode node;
        node = xml.SelectSingleNode("configuration/applicationSettings/MyApp.Properties.Settings/setting[@name='myparam1']");
        node.ChildNodes[0].InnerText = myNewValue;
        xml.Save(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
    

    In this way, I create a xml document (xml variable) and load the information of the app.config file. Then, I search for the node that I want to update, update its information (InnerText property) and finally I save the changes.

    In this way, I can update the app.config. It is what I want, because in a portable application, only one user will use it, and I want that the configuration is applied in any computer in which I run the application.

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

Sidebar

Related Questions

I would like to open a popup window using javascript in my c#.net app.
I'm using : log_file = AWS::S3::Bucket.logs_for('downloads.idance.net').first I would then like to delete each file
Using the .NET System.ServiceModel.Syndication classes... I would like to add a new SyndicationElementExtension to
Using ASP.Net, I have a server control for which i would like to add
I would like to know the version of ASP.NET supports using Windows AppFabric caching
I am designing a web application using the ASP.net MVC framework. I would like
Using log4net we would like to log all calls to our ASP.NET MVC controller
I'm using jQuery validation in ASP.net MVC. I would like to show validation summary
When using ASP.net webforms my usual solution would have following type of setup -
I am building a Windows form application using .NET 3.5. I would like to

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.