Here is a code snippet of how to compress one or many files to a zip archive in memory using C#.
It works in .Net Core and .Net Full Framework
public static byte[] GetZipArchive(params InMemoryFile[] files)
{
byte[] archiveFile;
using (var archiveStream = new MemoryStream())
{
using (var archive = new ZipArchive(archiveStream,