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 4615590
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:51:42+00:00 2026-05-22T01:51:42+00:00

This question is related to Winform application deployment and configuration. I am new to

  • 0

This question is related to Winform application deployment and configuration.

I am new to .net development and I am working on my first Winforms application. Whenever I deploy the application I need to set the value of the server to which the user will be connecting.

For this I have to go into program files and change the application configuration file manually using Notepad.

Not only have I heard that this is not a good practice, it is also a tedious exercise. Imagine going to half a dozen users and doing the same thing on each machine.

I am very confused as to what to do. The application config file that is in the same folder as the exe is the file thorugh which I can change the connection string (as I am given to understand).

Can anyone help me to solve the following questions.

  1. How do I update the application configuration file after I install it without having to open it up in Notepad? My main concern is updating the connection string.

  2. I have heard that using the registry is a possibility in this case. I am scared of using the registry! Is this an option?

Please excuse my ignorance if the questions are naive. I am new to .net and looking for answers

Thanks
Romi

  • 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-22T01:51:43+00:00Added an answer on May 22, 2026 at 1:51 am

    Hi Romi here is a code snippet that can help you in read/right application configurations

    for write in the

         System.Configuration.Configuration config =
         ConfigurationManager.OpenExeConfiguration
                    (ConfigurationUserLevel.None);
    
        // Add an Application Setting.
    
        config.AppSettings.Settings.Add("ModificationDate",
                       DateTime.Now.ToLongTimeString() + " ");
    
        // Save the changes in App.config file.
    
        config.Save(ConfigurationSaveMode.Modified);
    
        // Force a reload of a changed section.
    
        ConfigurationManager.RefreshSection("appSettings");
    

    to read

        foreach(string key in ConfigurationManager.AppSettings)
        {
           string value = ConfigurationManager.AppSettings[key];
           Console.WriteLine("Key: {0}, Value: {1}", key, value);
        }
    

    my advice: if your are saving several settings that are not connection strings use the above code. just create a simple form, create a dictionary fill it and show it using a grid control.

    if you only need to read/write connection strings use the following code

    to read

      string cnx =      ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
    

    to write

         ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString=" your conenction string here";
    

    config.Save(ConfigurationSaveMode.Modified);

        // Force a reload of a changed section.
    
        ConfigurationManager.RefreshSection("ConnectionString");
    

    you can still use the registry to save those settings but I belive the code above will solve your problems.

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

Sidebar

Related Questions

My question is related to this question: Baseline snaplines in custom Winforms controls However,
Note first of all that this question is not tagged winforms or wpf or
This is related to Alternate Application.Run Winform In Program.cs File I have created textfile
Please note this question related to performance only. Lets skip design guidelines, philosophy, compatibility,
This question is related to (but perhaps not quite the same as): Does Django
This question is related to another question which I asked yesterday! List all links
This question is related to a previous post of mine Here . Basically, I
[This question is related to but not the same as this one .] My
This question is related to this one , though I think I was a
[This question is related to but not the same as this one .] If

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.