.net framework 2.0以上修改config配制更容易
读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;
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;