CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Location
    G day Mayt Land
    Posts
    971

    [RESOLVED] Saving into config file

    To Save into config file
    Code:
                   string strJob = textBox4.Text+".Name";
                    string strValue = textBox4.Text+","+textBox9.Text;
                    System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                    try
                    {
                        config.AppSettings.Settings.Add(strJob, strValue);
                    }
                    catch
                    {
                        MessageBox.Show("can not Add " + strJob + "=" + strValue);
                    }
    
                    config.Save(ConfigurationSaveMode.Modified);

    and to view what i have
    Code:
                string strTotal=null;
                foreach (string key in ConfigurationManager.AppSettings)
                {
                    string value = "NConfigurationManager.AppSettings[key];
                    strTotal += value + "\r\n";
                }
    
                MessageBox.Show(strTotal);
    When does the saving actually takes place? as I dont see what has been added has been saved?

  2. #2
    Join Date
    May 1999
    Location
    G day Mayt Land
    Posts
    971

    Re: Saving into config file

    ConfigurationManager.RefreshSection("appSettings"); was being missed out after the final save.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured