C# read and write config configuration file

1. In App.config, we add appSettings node, and then add configuration information in appSettings

 2. Add System.Configuration reference

 3. Operate App.config;

Reference the namespace in the corresponding class before the operation: using System.Configuration;

3.1: Read data

 string ServiceUrl = ConfigurationManager.AppSettings["CheckUpdatesUrl"];

3.2: Modify data

 Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
 cfa.AppSettings.Settings["CheckUpdatesUrl"].Value ="xxxx";
 cfa.Save(ConfigurationSaveMode.Modified);

Guess you like

Origin blog.csdn.net/qq_29728817/article/details/127887698