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操作各類時(shí)間段獲取方法匯總
- ASP.NET批量操作基于原生html標(biāo)簽的無序列表的三種方法
- asp.net操作javascript:confirm返回值的兩種方式
- 一個(gè)ASP.NET的MYSQL的數(shù)據(jù)庫操作類自己封裝的
- Asp.Net中Cache操作類實(shí)例詳解
- ASP.net中獲取客戶端參數(shù)操作系統(tǒng)信息
- asp.net操作xml增刪改示例分享
- asp.net 操作cookie的簡單實(shí)例
- Asp.Net用OWC操作Excel的實(shí)例代碼
- ASP.NET中操作SQL數(shù)據(jù)庫(連接字符串的配置及獲取)
- asp.net中Repeart選中整行操作實(shí)例
相關(guān)文章
asp.net FileUpload控件實(shí)現(xiàn)文件格式判斷與文件大小限制
這篇文章主要介紹了有關(guān)asp.net fileupload控件判斷文件格式,以及進(jìn)行文件大小限制的方法,可以在web.config中配置,也可以在.cs文件中實(shí)現(xiàn),需要的朋友參考下2014-11-11.Net平臺開發(fā)實(shí)踐的一些點(diǎn)滴總結(jié)(技術(shù)規(guī)范與實(shí)踐精華)
以下是本人對.Net平臺開發(fā)實(shí)踐的一些點(diǎn)滴總結(jié)。這里的技術(shù)規(guī)范主要是開發(fā)過程的代碼規(guī)范、數(shù)據(jù)庫設(shè)計(jì)規(guī)范、Com和.Net互操作規(guī)范;實(shí)踐精華是對技術(shù)實(shí)踐過程中的部分總結(jié)。2010-04-04解決asp.net core在輸出中文時(shí)亂碼的問題
最近在學(xué)習(xí)asp.net core的時(shí)候,嘗試在控制臺,或者頁面上輸出中文,會出現(xiàn)亂碼的問題。那么這該如何解決呢?下面通過這篇文章來一起看看吧,文中給出了詳細(xì)的解決方法,相信對大家有一定的參考價(jià)值。2016-12-12VS2015使用scanf報(bào)錯(cuò)的解決方法
這篇文章主要為大家詳細(xì)介紹了VS2015使用scanf報(bào)錯(cuò)的解決方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-01-01