asp.net操作ini文件示例
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>
public class INIFile
{
public string path;
public INIFile(string INIPath)
{
path = INIPath;
}
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section,
string key, string val, string filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section,
string key, string def, StringBuilder retVal, int size, string filePath);
public void IniWriteValue(string Section, string Key, string Value)
{
WritePrivateProfileString(Section, Key, Value, this.path);
}
public string IniReadValue(string Section, string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path);
return temp.ToString();
}
}
}
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, EventArgs e)
{
CreateWebDir.INIFile ab = new CreateWebDir.INIFile(@"F:\test");
string iniFile = @"F:\test\test.ini";
if (!File.Exists(iniFile))
{
using (FileStream fs = File.Create(iniFile))
{
fs.Close();
}
}
string[] args = new string[10];
CreateWebDir.INIFile myINI = new CreateWebDir.INIFile(iniFile);
for (int i = 0; i < args.Length; i++)
{
args[i] = Convert.ToString(i + i * i * i);
myINI.IniWriteValue("WebDir", "arg" + i.ToString(), args[i]);
}
}
}
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, EventArgs e)
{
CreateWebDir.INIFile ab = new CreateWebDir.INIFile(@"F:\test\test.ini");
Response.Write(ab.IniReadValue("WebDir", "arg5"));
}
}
- ASP.NET操作各類時間段獲取方法匯總
- ASP.NET批量操作基于原生html標(biāo)簽的無序列表的三種方法
- asp.net操作javascript:confirm返回值的兩種方式
- 一個ASP.NET的MYSQL的數(shù)據(jù)庫操作類自己封裝的
- Asp.Net中Cache操作類實例詳解
- ASP.net中獲取客戶端參數(shù)操作系統(tǒng)信息
- asp.net操作xml增刪改示例分享
- asp.net 操作cookie的簡單實例
- Asp.Net用OWC操作Excel的實例代碼
- ASP.NET中操作SQL數(shù)據(jù)庫(連接字符串的配置及獲取)
- asp.net中Repeart選中整行操作實例
相關(guān)文章
Asp.net core WebApi 使用Swagger生成幫助頁實例
本篇文章主要介紹了Asp.net core WebApi 使用Swagger生成幫助頁實例,具有一定的參考價值,感興趣的小伙伴們可以參考一下。2017-04-04
ASP.NET?MVC使用typeahead.js實現(xiàn)輸入智能提示功能
這篇文章介紹了ASP.NET?MVC使用typeahead.js實現(xiàn)輸入智能提示功能的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-09-09
.NET Core中使用Redis與Memcached的序列化問題詳析
這篇文章主要介紹了.NET Core中使用Redis與Memcached的序列化問題的相關(guān)內(nèi)容,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。2018-03-03
MVC后臺創(chuàng)建Json(List)前臺接受并循環(huán)讀取實例
MVC后臺創(chuàng)建Json(List)同時前臺接受并循環(huán)讀取,具體實現(xiàn)代碼如下,感興趣的朋友可以參考下哈,希望對大家有所幫助2013-06-06
完美解決Could not load file or assembly AjaxPro.2 or one of its
Could not load file or assembly AjaxPro.2,經(jīng)排查原來是mcafee限制了2007-08-08
SqlCommandBuilder類批量更新excel或者CSV數(shù)據(jù)的方法
這篇文章主要介紹了SqlCommandBuilder類批量更新excel或者CSV數(shù)據(jù)的方法,需要的朋友可以參考下2015-10-10
MVC HtmlHelper擴(kuò)展類(PagingHelper)實現(xiàn)分頁功能
這篇文章主要為大家詳細(xì)介紹了MVC HtmlHelper擴(kuò)展,實現(xiàn)分頁功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-05-05
.Net?Core?Aop之IResourceFilter的具體使用
本文主要介紹了.Net?Core?Aop之IResourceFilter的具體使用,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-02-02

