C# Create Zip With Streams

Date: 2021-06-10
public byte[] CreateZipWithStreams(List<StreamInfo> streams)
{
	using var memoryStream = new MemoryStream();
	using var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true);
	foreach (var streamInfo in streams)
	{
		streamInfo.Stream.Position = 0;
		var zipItem = archive.CreateEntry(streamInfo.Name);
		using var entryStream = zipItem.Open();
		streamInfo.Stream.CopyTo(entryStream);
	}
	return memoryStream.ToArray();
}
51120cookie-checkC# Create Zip With Streams