1. 程式人生 > >C#讀寫config配置文件

C#讀寫config配置文件

style get evel nbsp app oid sta add none

class Config
    {
        static Configuration _config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

        private Config()
        {
            
        }

        static public void AddAppSetting(string key, string value)
        {
            _config.AppSettings.Settings.Add(key, value);
            _config.Save();
        }

        
static public void SetAppSetting(string key, string value) { _config.AppSettings.Settings.Remove(key); _config.AppSettings.Settings.Add(key, value); _config.Save(); } static public string GetAppSetting(string key) { return
_config.AppSettings.Settings[key].Value; } static public void DelAppSetting(string key) { _config.AppSettings.Settings.Remove(key); _config.Save(); } }

C#讀寫config配置文件