Add "System.Configuration" reference to your application
ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();
configFileMap.ExeConfigFilename = @"{path}";
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
Console.WriteLine(config.AppSettings.Settings["YourKey"].Value);
config.AppSettings.Settings["YourKey"].Value = DateTime.Now.Date.ToString("yyMMdd");
config.Save();
ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();
configFileMap.ExeConfigFilename = @"{path}";
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
Console.WriteLine(config.AppSettings.Settings["YourKey"].Value);
config.AppSettings.Settings["YourKey"].Value = DateTime.Now.Date.ToString("yyMMdd");
config.Save();
No comments:
Post a Comment