using Nini.Ini;
using Nini.Config;
IniDocument doc = new IniDocument("Settings.ini", IniFileType.WindowsStyle);
IniConfigSource source = new IniConfigSource(doc);
source.Configs["[System]"].Set("InstallDirectory", acmInstallDirTextbox.Text);
source.Save();
=>
Try following code:
IniConfigSource source = new IniConfigSource("Settings.ini");
source.Configs["System"].Set("InstallDirectory", @"C:\Program Files(x86)\Test");
source.Save();
or
IniDocument doc = new IniDocument("Settings.ini", IniFileType.WindowsStyle);
doc.Sections["System"].Set("InstallDirectory", @"C:\Program Files(x86)\Test2");
doc.Save("Settings.ini");
原文:http://www.cnblogs.com/zeroone/p/3536567.html