C # configuration file operations,
Note: Add reference: System. Configuration;
Using System; using System. collections. generic; using System. text; using System. configuration; namespace DotNet. utilities. configuration file operation class {public class ConfigHelper_sufei {/// <summary> /// obtain the Value based on the Key /// </summary> /// <param name = "key"> </param> public static string GetValue (string key) {return ConfigurationManager. appSettings [key]. toString (). trim ();} /// <summary> /// modify Value based on Key /// </summary> /// <param name = "key"> Key to be modified </param>/ // <param name = "value"> value to be modified </param> public static void SetValue (string key, string value) {ConfigurationManager. appSettings. set (key, value) ;}/// <summary> /// Add a new Key, value key-value Pair /// </summary> /// <param name = "Key"> key </param> /// <param name = "Value"> Value </param> public static void Add (string key, string value) {ConfigurationManager. appSettings. add (key, value );} /// <summary> /// delete an item based on the Key /// </summary> /// <param name = "key"> Key </param> public static void Remove (string key) {ConfigurationManager. appSettings. remove (key );}}}
ConfigHelper