DotNetZip - Calculate final zip size before calling Save(stream)

When using DotNetZip, is it possible to get what the final zip file size will be before calling Save(stream)? I have a website where users will be downloading fairly large zip files (over 2 gigs), and I would like to be able to stream the file to the user rather then buffering the entire file into memory. Some thing like this...

response.BufferOutput = false; response.AddHeader("Content-Length", ????);

Is this possible?


If the stream is homogenous, you could waste some time by compressing a 'small' portion ahead, calculating the compression ratio and extrapolating from that.

If you are meaning to set a content-length header or something like that, it can only be done when you (1) write a temporary file (advisable if there is any risk of connection trouble and clients requesting specific chunks anyway) (2) can keep the entire file in memory (presumably on ly on 64bit system with copious memory)

Of course, you could waste enormous resources and just compress the stream twice, but I hope you agree that would be silly.


The way to do what you want is to save the file to a temporary filesystem file, then stream the result to the user. This lets you compute the size then transmit the file.

In this case dotnetzip will not save the file into memory.


  • Dropbox .NET Downloading large files using GetContentAsStreamAsync
  • extracting scale matrix from modelview matrix
  • legacyCasModel=“true” and dynamic data/operations
  • Creating a Cube-based 3-Dimensional Game
  • One Note Api rejects Bearer Token, Error 401
  • downloading .zip file with maximum file size limit
  • While using two static library in project, conflict due to class with same name compiled in both sta
  • Android: Adding Layouts Dynamically By Inflating XML
  • Why are files are different when downloading from an ASP.NET (AJAX download with Blob)
  • How to use make_transform_iterator() with counting_iterator and execution_policy in Thrust?
  • TextBox controls are not Working with Export To PDF(iTextSharp)
  • How can I prevent the need to copy strings passed to a avr-gcc C++ constructor?
  • Available space left on drive - WinAPI - Windows CE
  • Where these are stored?
  • Spark job failing in YARN mode
  • Listbox within Listbox and scrolling trouble in Windows Phone 7 Silverlight
  • Align navbar back button on right side
  • DotNetZip - Calculate final zip size before calling Save(stream)
  • AES padding and writing the ciphertext to a disk file
  • How to add date and time under each post in guestbook in google app engine
  • Possible to stop flickering java tooltip in heavyweight mode?
  • How to model a transition system with SPIN
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • Is there a mandatory requirement to switch app.yaml?
  • retrieve vertices with no linked edge in arangodb
  • File upload with ng-file-upload throwing error
  • ExecuteAsync RestSharp to allow backgroundWorker CancellationPending c#
  • AngularJs get employee from factory
  • Benchmarking RAM performance - UWP and C#
  • Load html files in TinyMce
  • Free memory of cv::Mat loaded using FileStorage API
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Cant find why the layout is getting smaller
  • Change div Background jquery
  • How to stop GridView from loading again when I press back button?
  • apache spark aggregate function using min value
  • Bitwise OR returns boolean when one of operands is nil
  • sending mail using smtp is too slow
  • costura.fody for a dll that references another dll
  • Binding checkboxes to object values in AngularJs