您的位置:首页 > 编程语言 > C#

C#读写INI

2011-05-05 11:21 85 查看
//读写INI
public class GF_INI
{
[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.dll")]
public static extern int Beep(int dwFreq, int dwDuration);
//读ini
public static void iniFile_SetVal(string in_filename, string Section, string Key, string Value)
{
WritePrivateProfileString(Section, Key, Value, in_filename);
}
//写INI
public static string iniFile_GetVal(string in_filename, string Section, string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section, Key, "", temp, 255, in_filename);
if (i == 0)
return "";
else
return temp.ToString();
}
}
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c# string ini class