2

So,I have the following piece of code to create and download a zip file

public virtual ActionResult Index()
   {
        using (var zipFile = new MemoryStream())
        {
            using (ZipArchive archive = new ZipArchive(zipFile, ZipArchiveMode.Create))
            {
                //add more files
                archive.CreateEntryFromFile(@"C:\Temp\HugeFile.iso", "HugeFile.iso", CompressionLevel.NoCompression);
            }
            return File(zipFile.ToArray(), "application/zip", "MyZip.zip");
        }
    }

It works fine but imagine I have a 10GB file,I will run out of memory.

If there I way to download the zip file while it is being created (so it's not taking much space in memory)?

Thanks

George Vovos
  • 7,563
  • 2
  • 22
  • 45

0 Answers0