在Visual C#中编辑Ini文件

时间:2015-06-14 02:01:44

标签: c# ini

我正在尝试使用它来编辑ini,但我似乎无法获取将ini文件的部分添加到RichTextbox中的代码。

int

我不知道我的代码有什么问题。

1 个答案:

答案 0 :(得分:0)

您可以使用来自Windows的旧的现有ini调用:

[System.Runtime.InteropServices.DllImport("kernel32")]
static extern int GetPrivateProfileString(string section,
        string key, string def, StringBuilder retVal,
        int size, string filePath);
[System.Runtime.InteropServices.DllImport("kernel32")]
static extern long WritePrivateProfileString(string section,
        string key, string val, string filePath);

...

StringBuilder temp = new StringBuilder(255);
GetPrivateProfileString("section", "key", "default", temp, 255, inifilename);
String value = temp.ToString();


WritePrivateProfileString("section", "key", value, inifilename);
相关问题