配置文件的几种读取方式

 private void button1_Click(object sender, EventArgs e)
        {
            //指定路径的方式
          object obj=  AppConfig访问方式.Properties.Settings.Default.Setting;
          MessageBox.Show(obj.ToString());
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //通过索引的方式
            AppSettingsReader app = new AppSettingsReader();
            string str = app.GetValue("user1", typeof(string)).ToString();
            MessageBox.Show(str);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            object obj = ConfigurationSettings.AppSettings["user1"];
            MessageBox.Show(obj.ToString());
        }

 附件:https://files.cnblogs.com/files/BABLOVE/AppConfig%E8%AE%BF%E9%97%AE%E6%96%B9%E5%BC%8F.rar

posted @ 2015-04-28 09:22  如梦不是梦  阅读(220)  评论(0编辑  收藏  举报