/// <summary> /// Saves the settings to an ini file. /// </summary> public void Save() { try { var data = new IniData { Configuration = IniParserConfig }; foreach (var setting in Children.OfType <Settings>()) { data.Merge(setting.GetIniData()); } using (var stream = File.Create($"{Name}.ini")) using (var writer = new StreamWriter(stream)) { var ini = new IniParser.StreamIniDataParser(); ini.WriteData(writer, data); } } catch (Exception e) { Engine.Logger.Error(e); throw new InvalidOperationException($"Could not save ini for ${Name}. (${ClassName}): {e.Message}", e); } }
public void Save() { var streamIni = new IniParser.StreamIniDataParser(); using (var writer = new StreamWriter(_stream)) { streamIni.WriteData(writer, _iniData); _stream.Flush(); _stream.Position = 0; } }