public static void WriteLevel(Level level, List<DummyObject> objects, FileInfo filePathAndName) { if (!filePathAndName.Name.Contains(".lvl")) { filePathAndName = new FileInfo(filePathAndName.Name + ".lvl"); } if (File.Exists(filePathAndName.FullName)) { File.Delete(filePathAndName.FullName); } FileStream output = File.Create(filePathAndName.FullName); ZipOutputStream zipStream = new ZipOutputStream(output); List<Tuple<string, MemoryStream>> serializedLevel = level.Serialize(); serializedLevel.Add(SerializedDummies(objects)); zipStream.SetLevel(5); foreach (Tuple<string, MemoryStream> file in serializedLevel) { ZipEntry newEntry = new ZipEntry(file.Item1); newEntry.DateTime = DateTime.Now; zipStream.PutNextEntry(newEntry); StreamUtils.Copy(file.Item2, zipStream, new byte[4096]); zipStream.CloseEntry(); } zipStream.IsStreamOwner = true; zipStream.Close(); }