I have this code, where zipfilename
is an existing Zip file, sourceFile
is a file I want to compress, and filename
is the archive entry name.
using (ZipArchive archive = ZipFile.Open(zipfilename, ZipArchiveMode.Update))
{
await Task.Run(() => archive.CreateEntryFromFile(sourceFile, filename, CompressionLevel.Fastest));
}
This works great for small files, no larger than say 50KB. For these, the file is compressed into the archive no problem. I can add as many small files as I want this way.
But for very large files 1.8GB in size, memory consumption shoots up to several GB, and the file never actually compresses into the archive.
How can I better handle compressing large files into an existing destination archive? Note that I need to use an existing destination zip / archive file, and it must be .zip.