Configuration与ConfigurationManager修改配置信息

读取配置:


    DStxtReadConfig.Text = ConfigurationManager.ConnectionStrings["bjxingchConnection"].ConnectionString.ToString();


设置配置信息:


    Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

                            config.ConnectionStrings.ConnectionStrings["bjxingchConnection"].ConnectionString = DStxtSaveConfig.Text;

    config.Save(ConfigurationSaveMode.Modified);

    ConfigurationManager.RefreshSection("connectionStrings");



    ConfigurationManager.RefreshSection("connectionStrings");  立即更新该节点,如果不使用这句话更新将在程序下次启动时更新

你可能感兴趣的:(信息)