asp.net 操作INI文件的读写,读写操作本地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(); int i = GetPrivateProfileString(Section, Key, "", temp, , 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[]; CreateWebDir.INIFile myINI = new CreateWebDir.INIFile(iniFile); for (int i = ; 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 操作INI文件的读写,读写操作本地ini配置文件的更多相关文章
- C#操作txt文件并清空添加操作
C#操作txt文件,进行清空添加操作的例子.代码: //把txt清空 FileStream stream = File.Open(Adr,FileMode.OpenOrCreate,FileAcces ...
- 八. 输入输出(IO)操作7.文件的随机读写
Java.io 包提供了 RandomAccessFile 类用于随机文件的创建和访问.使用这个类,可以跳转到文件的任意位置读写数据.程序可以在随机文件中插入数据,而不会破坏该文件的其他数据.此外,程 ...
- 无废话Android之android下junit测试框架配置、保存文件到手机内存、android下文件访问的权限、保存文件到SD卡、获取SD卡大小、使用SharedPreferences进行数据存储、使用Pull解析器操作XML文件、android下操作sqlite数据库和事务(2)
1.android下junit测试框架配置 单元测试需要在手机中进行安装测试 (1).在清单文件中manifest节点下配置如下节点 <instrumentation android:name= ...
- Python之文件操作:文件、目录的操作
一.创建 1.创建文件 open(path,'w') 2.创建目录 (1)os.mkdir(pt[, mode=0777]) 新建一个目录pt,参数mode表示生成的目录的权限,默认是超级权限,也就是 ...
- C#读写ini文件操作
ini文件,是windows操作系统下的配置文件,ini文件是一种按照特点方式排列的文本文件,它的构成分为三部分,结构如下: [Section1] key 1 = value2 key 1 = val ...
- 读写ini文件
C# 使用文件流来读写ini文件 背景 之前采用ini文件作为程序的配置文件,觉得这种结构简单明了,配置起来也挺方便.然后操作方式是通过WindowsAPI,然后再网上找到一个基于WindowsAPI ...
- 如何在C#中读写INI文件
INI文件就是扩展名为"ini"的文件.在Windows系统中,INI文件是很多,最重要的就是"System.ini"."System32.ini&q ...
- Delphi ini文件读写
参考:http://www.cnblogs.com/zhangzhifeng/archive/2011/12/01/2270267.html 一.ini文件的结构 ;这是关于 ini 文件的注释 [节 ...
- Delphi INI 文件读写
delphi中,配置文件的相关操作. () INI文件的结构: ;这是关于INI文件的注释部分 [节点] 关键字=值 ... INI文件允许有多个节点,每个节点又允许有多个关键字, “=”后面是该关键 ...
- C# ini文件操作【源码下载】
介绍C#如何对ini文件进行读写操作,C#可以通过调用[kernel32.dll]文件中的 WritePrivateProfileString()和GetPrivateProfileString()函 ...
随机推荐
- jackson 常见问题
org.codehaus.jackson.map.JsonMappingException: No suitable constructor found for type org.codehaus ...
- 杨佩昌:中国官员去德国考察看什么两眼发光 z
令中国人诧异的德国物价 只要是花费大量人工的行业,就很贵 □杨佩昌 德国是欧洲商品价格的洼地,连精明的瑞士人也开车到德国加油购物 一 2012年凤凰网组织十大著名博主前往澳洲考察并与前总理陆克文对话, ...
- xamarin for vs2013
安装需求(下载的包及版本) 先安装VS2013 然后到官网下Xamarin,运行后会自动下载以下文件 这是下载的详细列表 jdk-6u39-windows-i586.exe(69.73M) Andro ...
- Design T-Shirt
Design T-Shirt Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- 切换Oracle数据库实例
如果多个实例,需要切换可以采用以下命令: export ORACLE_SID=SID
- use isSubstring to check if one word is a rotation of another.
1: /// <summary> 2: /// Assume you have a method isSubstring which checks if one word is a s ...
- ACM2035_(递归法求幂)
/* 编写一个递归算法,求解m的n次方. 我们一般求解m的n次方,一般使用n个m相乘的办法来求解. 其实我们还可以使用另外一种更有效率的办法求解这个问题. 我们知道一个数的0次方等于1,一个数的1次方 ...
- 【解决】笔记本发射WiFi
这个百度一下一大堆 .. 不过还是希望自己总结一发适合自己的 (*^__^*) 废话不多说,开始 基于几个bat (1)CreateWlan.bat netsh wlan set hostednet ...
- 小Q书桌的下载、安装和使用
最近,无意之间,在某大牛电脑里,使用到了这款软件.感谢! 确实,挺实用和方便的,强烈推荐!!! 1. 下载 http://qdesk.qq.com/ 2. 安装 3. 使用 多么方便啊!
- 20169210《Linux内核原理与分析》第四周作业
网易云课堂学习: 在实验楼的学习中,这次的实验是利用mykernel实验模拟计算机硬件平台 首先进入linux-3.9.4, $cd LinuxKernel/linux-3.9.4 如下图所示 接下来 ...