|
WPF read/write config file sheet. 1. In your project, add the app.config file. The contents of the file default are:
2. If you want to configure some parameters for the program, <configuration>add them in the tag<appSettings>. For example, the following: 3. Then you can read and write it where you need it in the background program. Remember to add citations
using System.Configuration; 4. Read operation:
string strPath = ConfigurationManager.AppSettings["Path"]; 5. Write Operations:
Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); cfa. AppSettings.Settings["NAME"]. Value = "WANGLICHAO"; cfa. Save();
|