[RESOLVED] Saving into config file
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: [RESOLVED] Saving into config file

  1. #1
    Join Date
    May 1999
    Location
    G day Mayt Land
    Posts
    962

    [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
    962

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center