码迷,mamicode.com
首页 > 移动开发 > 详细

关于winform的appconfig的读写操作

时间:2014-05-19 11:21:03      阅读:279      评论:0      收藏:0      [点我收藏+]

标签:winform   style   blog   class   code   c   

bubuko.com,布布扣
 public string ReadConfig()
        {
            List<string> list = new List<string>();
            ExeConfigurationFileMap file = new ExeConfigurationFileMap();
            file.ExeConfigFilename = System.Windows.Forms.Application.ExecutablePath + ".config";
            Configuration config = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(file, ConfigurationUserLevel.None);

            var myApp = (AppSettingsSection)config.GetSection("appSettings");
            return myApp.Settings["lcc"].Value;
     
        }

        public string WriteConfig(string val)
        {
            ExeConfigurationFileMap file = new ExeConfigurationFileMap();
            file.ExeConfigFilename = System.Windows.Forms.Application.ExecutablePath + ".config";
            Configuration config = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(file, ConfigurationUserLevel.None);

            var myApp = (AppSettingsSection)config.GetSection("appSettings");
            myApp.Settings["lcc"].Value = val;
            config.Save();
            return val;

        }
bubuko.com,布布扣

 

关于winform的appconfig的读写操作,布布扣,bubuko.com

关于winform的appconfig的读写操作

标签:winform   style   blog   class   code   c   

原文地址:http://www.cnblogs.com/shikyoh/p/3731794.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!