This article mainly introduces the asp.net operation INI file reading and writing, read and write operation of the local INI configuration file method, the need for friends can refer to the following
Code as follows: using System; Using System.Data; Using System.Configuration; Using System.Web; Using System.Web.Security; Using System.Web.UI; Using System.Web.UI.WebControls; Using System.Web.UI.WebControls.WebParts; Using System.Web.UI.HtmlControls; using System.Runtime.InteropServices; Using System.Text; namespace Createwebdir { ///<summary> ///INIFile Summary description ///</s Ummary> public class INIFile { public string path;   ; public INIFile (string INIPath) { &NBSP ; Path = INIPath; } [DllImport ("kernel32")]- Priva Te static extern long WritePrivateProfileString (string section, string key, String Val, String filePath); &NBSP [DllImport ("kernel32")] private static extern int GetPrivateProfileString (string secti On, string key, String def, StringBuilder retVal, int size, string filePath); public void Iniwritevalue (string section, String Key, String Value) &NBSP ; { writeprivateprofilestring (section, Key, Value, This.path); &NBSP ; } public string Inireadvalue (string section, String Key) &N Bsp { StringBuilder temp = new StringBuilder (255); &NBSP ; int i = getprivateprofilestring (section, Key, "", temp, 255, this.path); return temp. ToString (); { }} code is as follows: using System; Using SysTem. Data; Using System.Configuration; Using System.Collections; Using System.Web; Using System.Web.Security; Using System.Web.UI; Using System.Web.UI.WebControls; Using System.Web.UI.WebControls.WebParts; Using System.Web.UI.HtmlControls; using System.IO; public partial class User_Default:System.Web.UI.Page { protected void Page_Load (object sender, even Targs e) { Createwebdir.inifile ab = new Createwebdir.inifile (@ "f:test"); String iniFile = @ "F:testtest.ini"; if (! File.exists (IniFile)) using (FileStream fs = File. Create (IniFile)) { FS. Close (); { string[] args = new STRING[10]; &nbSp Createwebdir.inifile Myini = new Createwebdir.inifile (INIFile); for (int i = 0; i < args. Length; i++) { Args[i] = convert.tostring (i + i * i * i); &n Bsp Myini.iniwritevalue ("WebDir", "Arg" + i.tostring (), args[i]); } /} code is as follows: using System; Using System.Data; Using System.Configuration; Using System.Collections; Using System.Web; Using System.Web.Security; Using System.Web.UI; Using System.Web.UI.WebControls; Using System.Web.UI.WebControls.WebParts; Using System.Web.UI.HtmlControls; using System.IO; public partial class User_Default:System.Web.UI.Page { protected void Page_Load (object sender, even Targs e) { Createwebdir.inifile ab = new Createwebdir.inifile (@ "F:testtest.ini") ; &NBSp Response.Write (AB. Inireadvalue ("WebDir", "Arg5")); }}