ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 【edobnet】.net framework 2.0以上修改config配制更容易

【edobnet】.net framework 2.0以上修改config配制更容易

原创 Linux操作系统 作者:iDotNetSpace 时间:2008-06-16 10:23:03 0 删除 编辑
读APPSETTING行简单:
 _nowVersion = ConfigurationManager.AppSettings["nowVersion"];

    以前与配制通过操作XML文件来进行,现在可以修改为以下方式:

 ExeConfigurationFileMap filemap = new ExeConfigurationFileMap();
            filemap.ExeConfigFilename 
= "AupdateConsole.exe.config";
            Configuration config 
= ConfigurationManager.OpenMappedExeConfiguration(filemap, ConfigurationUserLevel.None);

            config.AppSettings.Settings[
"nowVersion"].Value = _nowVersion;
            config.AppSettings.Settings[
"siteCode"].Value = _siteCode;
            config.AppSettings.Settings[
"siteName"].Value = _siteName;
            config.AppSettings.Settings[
"appId"].Value = _appId;
            config.AppSettings.Settings[
"appCode"].Value = _appCode;
            config.Save();
            
return true;

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12639172/viewspace-349321/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-01-04

  • 博文量
    2376
  • 访问量
    5769025