using System.Collections.Generic; using System.IO; using System.IO.Compression; public class ZipEngine { public byte[] ZipInMemory(Dictionary<string, byte[]> files) { using (var memoryStream = new MemoryStream()) { using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true)) { foreach (var file in files) { var entry = archive.CreateEntry(file.Key); using (var entryStream = entry.Open()) { entryStream.Write(file.Value, 0, file.Value.Length); } } } return memoryStream.ToArray(); } } }
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.