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(); } } }