1. Reading from App.config file:
    using System.Configuration;

    To read from app.config file you may use the following code:
    private string ReadFromAppConfig(string key)
    {
     return ConfigurationManager.AppSettings[key];
    }

    To write to app.config file you may use the following code:
    private void WriteToAppConfig(string key, string value)
    {
     Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
     config.AppSettings.Settings[key].Value  = value;
     config.Save(ConfigurationSaveMode.Modified);
     ConfigurationManager.RefreshSection("appSettings");
    }


    Sample App.Config file:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <appSettings>
        <add key="TimerInterval" value ="9000"/>
      </appSettings>
    </configuration>
    1

    View comments

Blog Archive
Topics
Topics
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.