INI文件的操作(ASP.NET+C#)
来源:互联网 发布:网络销售彩票工资高吗 编辑:程序博客网 时间:2024/05/17 02:32
INI文件的操作(ASP.NET+C#)
(一)INIFile.cs
using System;
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();
}
}
}
=======================================================
(二)使用示例
string iniFile = @"D:\Bug2000.ini";
if (!File.Exists(iniFile))
{
using (FileStream fs = File.Create(iniFile))
{
fs.Close();
}
}
INIFile myINI = new INIFile(iniFile);
for(i=0;i<args.Length;i++)
{
myINI.IniWriteValue("WebDir","arg"+i.ToString(),args[i]);
}
- INI文件的操作(ASP.NET+C#)
- INI文件的操作(ASP.NET+C#)
- .net 操作INI文件
- [C#.Net]在ASP.NET中操作文件的例子
- C#.Net ini file 操作
- VB.net ini文件操作
- INI文件的操作
- Ini文件的操作
- ini 文件的操作
- INI 文件的操作
- INI文件的操作
- INI文件的操作
- ini文件的操作
- INI文件的操作
- INI 文件的操作
- INI 文件的操作
- INI文件的操作
- INI文件的操作
- plsql如何连接64位Oracle数据库
- qt 5.2 使用mysql数据库,提示出错QSqlDatabase: QMYSQL driver not loaded
- Log图文详解(Log.v,Log.d,Log.i,Log.w,Log.e)
- 如果缘只到遇见,如果爱只为擦肩
- 苹果不再迷人:又一核心高管跳槽
- INI文件的操作(ASP.NET+C#)
- redis源码分析之RDB持久化
- myeclipse中hibernate实体类生成映射文件
- Oracle权限
- linux expect, spawn
- Spring MVC 如何防止XSS、SQL注入攻击
- ASP经典分页类
- Linux 中 crontab(linux下的定时执行工具) 详解及示例
- java、Extjs导出数据库里的数据至Excel并下载至本地进行数据备份方法之一——使用servlet