In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the example analysis of reading and writing Config files in ASP.NET, which is very detailed and has certain reference value. Friends who are interested must finish reading it!
The methods are as follows:
If it is a WinForm program, you need to add a reference:
System.ServiceModel
System.Configuration
App.config
NetUtilityLib
Using System.Configuration;namespace pcauto {public static class ConfigHelper {/ return the value entry / public static string GetAppConfig (string strKey) of the appSettings configuration section in the * .exe.config file {string file = System.Windows.Forms.Application.ExecutablePath; Configuration config = ConfigurationManager.OpenExeConfiguration (file) Foreach (string key in config.AppSettings.Settings.AllKeys) {if (key = = strKey) {return config.AppSettings.Settings.Value.ToString ();}} return null;} / add a pair of keys to the appSettings configuration section in the * .exe.config file / public static void UpdateAppConfig (string newKey, string newValue) {string file = System.Windows.Forms.Application.ExecutablePath Configuration config = ConfigurationManager.OpenExeConfiguration (file); bool exist = false; foreach (string key in config.AppSettings.Settings.AllKeys) {if (key = = newKey) {exist = true;}} if (exist) {config.AppSettings.Settings.Remove (newKey);} config.AppSettings.Settings.Add (newKey, newValue); config.Save (ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection ("appSettings");}
Read the example
ConfigHelper.GetAppConfig ("testkey")
Write an example
ConfigHelper.UpdateAppConfig ("testkey", "abc"); the above is all the contents of the article "sample Analysis of Config File Reading and Writing in ASP.NET". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.