public void Export(ScoreBook book) { using (var ms = new MemoryStream()) { var args = new ScoreBookExportPluginArgs(book, ms, IsQuick, GetCustomData, SetCustomData); Diagnostics = args.Diagnostics; ExportPlugin.Export(args); using (var fs = new FileStream(OutputPath, FileMode.Create, FileAccess.Write)) { var res = ms.ToArray(); fs.Write(res, 0, res.Length); } } }