title: How to update and save an app.config application setting programatically
body: <p>I am currently working on a WPF/.Net project, 
  In this project the user has the choice to change the the skinning of the app entirely, 
  I am trying to write those settings after submission using configurations management, 
  but I don't seem to be able to add the new values to the app.config file, here is my method underneath</p>
  
  <pre><code>Public Sub SetApplicationSetting(pstrAppSettingName As String, pstrAppSettingValue As String)
      Dim lobjconfig As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
  
      lobjconfig.AppSettings.Settings.Add(pstrAppSettingName, pstrAppSettingValue)
      lobjconfig.Save(ConfigurationSaveMode.Full)
      ConfigurationManager.RefreshSection("appSettings")
  End Sub
  </code></pre>
  
  <p>any ideas?</p>
  
  <p>Now the word on the street is that I cant Add to what is already there, So I thougth maybe I should remove it first before updating, 
  but still nothing,  here is the new code </p>
  
  <pre><code> Dim lobjconfig As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
  
              lobjconfig.AppSettings.Settings.Remove(pstrAppSettingName)
              lobjconfig.AppSettings.Settings.Add(pstrAppSettingName, pstrAppSettingValue)
  
  
                 lobjconfig.AppSettings.Settings.CurrentConfiguration.Save()
              lobjconfig.Save(ConfigurationSaveMode.Full, True)
  
          ConfigurationManager.RefreshSection("appSettings")
  </code></pre>