relaxlife.net .NET iniFile操作类



//*******************************************************************************
// OdbcHelper ODBC连接数据库方式
// [url]www.relaxlife.net[/url] 收藏
// QQ群:4341998
//*******************************************************************************
using System;
using System.Text;
using System.Runtime.InteropServices;

namespace Pub.Class
{
///
/// INI文件操作
///
public class iniFile
{
#region 私有成员
private string path;
[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);
#endregion

#region 构造器
///
/// 构造器
///
/// 文件名
public iniFile(string INIPath) { path = INIPath; }
#endregion

#region WriteValue
///
/// 向INI文件写数据
///
/// 结点
/// 名称
/// 值
public void WriteValue(string Section, string Key, string Value)
{
WritePrivateProfileString(Section, Key, Value, this.path);
}
#endregion

#region ReadValue
///
/// 向INI文件读数据
///
/// 结点
/// 名称
/// 数据
public string ReadValue(string Section, string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path);
return temp.ToString();
}
#endregion
}

}


附件附件:

您所在的用户组无法下载或查看附件

看帖回帖是每个网民应尽的义务...
喜欢的顶一下,楼主才会更有动力。