写一个操作 .ini文件的类
class inihelp
{
private string 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 inihelp(string inipath)
{
this.inipath = inipath;
}
public inihelp()
{
}
public void setfilepath(string filepath)
{
this.inipath = filepath;
}
public void iniwrite(string section,string key,string val)
{
writeprivateprofilestring(section,key,val,inipath);
}
public string inireadvalue(string section,string key)
{
stringbuilder temp=new stringbuilder(500);
int i=getprivateprofilestring(section,key,"",temp,500,inipath);
return temp.tostring();
}
public bool existinifile()
{
return file.exists(inipath);
}
}