asp.net 操作INI文件读写类实例代码
来源:才华咖 本文已影响3.23W人
来源:才华咖 本文已影响3.23W人
操作INI文件读写类实例代码
复制代码 代码如下:
using System;
using ropServices;
using ;
using ;
namespace Common
{
///
/// INI文件读写类。
///
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);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string defVal, Byte[] retVal, int size, string filePath);
///
/// 写INI文件
///
///
///
///
public void IniWriteValue(string Section,string Key,string Value)
{
WritePrivateProfileString(Section,Key,Value,);
}
///
/// 读取INI文件
///
///
///
///
public string IniReadValue(string Section,string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section,Key,"",temp, 255, );
return ring();
}
public byte[] IniReadValues(string section, string key)
{
byte[] temp = new byte[255];
int i = GetPrivateProfileString(section, key, "", temp, 255, );
return temp;
}
///
/// 删除ini文件下所有段落
///
public void ClearAllSection()
{
IniWriteValue(null,null,null);
}
///
/// 删除ini文件下personal段落下的所有键
///
///
public void ClearSection(string Section)
{
IniWriteValue(Section,null,null);
}
}
}
没有太多含量,做雕虫小技是还是用得上。
java中通用的线程池实例代码
让网站变灰的css代码实例
asp.net 操作INI文件读写类实例代码
PHP如何编写易读的代码
java构造函数实现代码示例
PHP实现大文件上传源代码
jQuery遍历Form示例代码
js代码改写成jq代码的方法
商务写作:英文邮件九类例句
C语言合并排序及实例代码
jquery下json数组的操作如何实现代码
个人简历写作范例:Asp.net高级程序员
php解析ini配置文件
jQuery实现左右图片轮播代码操作方法
php验证码代码怎么写
PHP开发微信支付实例代码
jquery异步请求的实例代码
C#实现协同过滤算法的实例代码
JavaScript实现的div拖动效果实例代码
php实现无限级分类实现代码
PHP中检测ajax请求的代码实例
关于ASP.NET使用JavaScript显示信息提示窗口实现原理及代码
C语言快速排序实例代码
PHP类商品秒杀计时实现代码
如何写代码