首页上一页 1 下一页尾页 1 条记录 1/1页
关于ini文件读写
发表在C#图书答疑
2010-03-31
是否精华
是
否
版块置顶:
是
否
老师你好,在连数据库时(无论是SQL还是Oracle),老板都给了我们一个负责ini文件读写的公共类,看不懂啊,能帮解释下嘛,它完成什么功能(通俗易懂点啊)谢谢您!
namespace sysDialog
{
/**/
/// <summary>
/// Create a New INI file to store or load data
/// </summary>
public class clsINI
{
public 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);
/**//// <summary>
/// INIFile Constructor.
/// </summary>
/// <PARAM name=\"INIPath\"></PARAM>
public clsINI(string INIPath)
{
path = INIPath;
}
/**//// <summary>
/// Write Data to the INI File
/// </summary>
/// <PARAM name=\"Section\"></PARAM>
/// Section name
/// <PARAM name=\"Key\"></PARAM> [Page]
/// Key Name
/// <PARAM name=\"value\"></PARAM>
/// value Name
public void IniWritevalue(string Section,string Key,string value)
{
WritePrivateProfileString(Section,Key,value,this.path);
}
/**//// <summary>
/// Read Data value From the Ini File
/// </summary>
/// <PARAM name=\"Section\"></PARAM>
/// <PARAM name=\"Key\"></PARAM>
/// <PARAM name=\"Path\"></PARAM>
/// <returns></returns>
public string IniReadvalue(string Section,string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section,Key,"",temp, 255, this.path);
return temp.ToString();
}
}
}
namespace sysDialog
{
/**/
/// <summary>
/// Create a New INI file to store or load data
/// </summary>
public class clsINI
{
public 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);
/**//// <summary>
/// INIFile Constructor.
/// </summary>
/// <PARAM name=\"INIPath\"></PARAM>
public clsINI(string INIPath)
{
path = INIPath;
}
/**//// <summary>
/// Write Data to the INI File
/// </summary>
/// <PARAM name=\"Section\"></PARAM>
/// Section name
/// <PARAM name=\"Key\"></PARAM> [Page]
/// Key Name
/// <PARAM name=\"value\"></PARAM>
/// value Name
public void IniWritevalue(string Section,string Key,string value)
{
WritePrivateProfileString(Section,Key,value,this.path);
}
/**//// <summary>
/// Read Data value From the Ini File
/// </summary>
/// <PARAM name=\"Section\"></PARAM>
/// <PARAM name=\"Key\"></PARAM>
/// <PARAM name=\"Path\"></PARAM>
/// <returns></returns>
public string IniReadvalue(string Section,string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section,Key,"",temp, 255, this.path);
return temp.ToString();
}
}
}