//读取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文件
最新推荐文章于 2023-09-25 09:57:59 发布