public static void UpdateIniFile(string fileName, string handler, string[] names, string[] values, MigratorAction[] actions) { if (File.Exists(fileName + ".example"))//Update the .example files too if people haven't { UpdateIniFile(fileName + ".example", handler, names, values, actions); } if (File.Exists(fileName)) { IniConfigSource doc = new IniConfigSource(fileName, IniFileType.AuroraStyle); IConfig section = doc.Configs[handler]; for (int i = 0; i < names.Length; i++) { string name = names[i]; string value = values[i]; MigratorAction action = actions[i]; if (action == MigratorAction.Add) { section.Set(name, value); } else { section.Remove(name); } } doc.Save(); } }
public static void UpdateIniFile(string fileName, string handler, string[] names, string[] values, MigratorAction[] actions) { if (File.Exists(fileName + ".example")) //Update the .example files too if people haven't UpdateIniFile(fileName + ".example", handler, names, values, actions); if (File.Exists(fileName)) { IniConfigSource doc = new IniConfigSource(fileName, IniFileType.AuroraStyle); IConfig section = doc.Configs[handler]; for (int i = 0; i < names.Length; i++) { string name = names[i]; string value = values[i]; MigratorAction action = actions[i]; if (action == MigratorAction.Add) section.Set(name, value); else section.Remove(name); } doc.Save(); } }