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

Very simple, right?

Here is a sample Console Application in C# .Net Core.

References: