寫一個操作 .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);
}

}


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2020 ITdaan.com