Environment vs2010
Reading is very simple and basically used [""].ToString()
Writing config is not very common. The code is as follows:
Copy the codeThe code is as follows:
/// <summary>
/// Modify the value of an item in the configuration file
/// </summary>
/// <param name="key">appSettings' key</param>
/// <param name="value">appSettings' Value</param>
public static void SetConfig(string key, string value)
{
Configuration config = ();
if ([key] != null)
[key].Value = value;
else
(key, value);
();
("appSettings");
}
But when I was debugging, I found that the contents in the project had not changed. If you don't debug (the debug file under the project is found between the debug file) you run the exe file and find that the file has changed.
reason:
When we debug (press F5), the compiler will overwrite the exe, dll, and config under debug. Then execute the exe file and (used when debugging this file). This will change the config content under debug.
The files under the project have not changed. . . So when debugging next time, the config under debug is overwritten again. . So I saw what I mentioned above. .