title: How to Write to app.config in setup project and use it in the program
body: <ul>
  <li>I have created a Installhelper.cs which is inhered from the Installer.</li>
  <li>Override the Install() method by using this piece of code(A).</li>
  </ul>
  
  <p>These values that are inserted to the app.config are not available in the <strong>[projectName].exe.config file</strong> that is created after installation.
  I have already added a section as shown below in the app.config manually (B)</p>
  
  <p>data is passed to the installer class but the data is not written to the app.config fields. They remain same in the created configuration file during installation.</p>
  
  <p>Any Help is greatly appreciated. I have spent almost a day on this.</p>
  
  <p>Code A:</p>
  
  <pre><code>[RunInstaller(true)]
  public partial class Installation : System.Configuration.Install.Installer
  {
      public Installation()
      {
          InitializeComponent();
      }
  
      public override void Install(IDictionary stateSaver)
      {
          //base.Install(stateSaver);
  
          try
          {
              // In order to get the value from the textBox named 'EDITA1' I needed to add the line:
              // '/PathValue = [EDITA1]' to the CustomActionData property of the CustomAction We added. 
  
              string userName = Context.Parameters["userName"];
              string password = Context.Parameters["password"];
              string folderPath = Context.Parameters["path"];
  
              MessageBox.Show(userName);
              MessageBox.Show(password);
              MessageBox.Show(folderPath);
  
              Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
             //config.AppSettings.Settings.Add("userName", userName);
             //config.AppSettings.Settings.Add("password", password);
             //config.AppSettings.Settings.Add("foderPath", folderPath);
  
  
  
  
  
              config.AppSettings.Settings["userName"].Value = userName;
              config.AppSettings.Settings["password"].Value = password;
              config.AppSettings.Settings["foderPath"].Value = folderPath;
              config.Save(ConfigurationSaveMode.Full);
              ConfigurationManager.RefreshSection("appSettings");
  
  
  
  
          }
          catch (FormatException e)
          {
              string s = e.Message;
              throw e;
          }
      }
  }
  </code></pre>
  
  <p>Added section in the app config is 
  Code B:</p>
  
  <pre><code>&lt;appSettings&gt;
  &lt;add key="userName" value="" /&gt;
  &lt;add key="password" value="" /&gt;
  &lt;add key="foderPath" value="" /&gt;
  &lt;/appSettings&gt;
  </code></pre>