//读取ini文件
public string GetLicenseKey()
{
string s = string.Empty;
return ReadIniData(“License”, “key”, s, System.Environment.CurrentDirectory + “\SystemLicense.ini”);
}
//读取ini文件
public static string ReadIniData(string Section, string Key, string NoText, string iniPath)
{
if (File.Exists(iniPath))
{
StringBuilder temp = new StringBuilder(1024);
GetPrivateProfileString(Section, Key, NoText, temp, 1024, iniPath);
return temp.ToString();
}
else
{
return String.Empty;
}
}
//写ini文件
public static bool WriteIniValue(string Section, string Key, string Value, string iniPath)
{
if (File.Exists(iniPath))
{
if (WritePrivateProfileString(Section, Key, Value, iniPath)>0)
{
return true;
}
else
{
return false;
}
}
return true;
}
C#之读写ini文件
最新推荐文章于 2024-07-07 07:00:00 发布