BufferSize Property

DotNetZip

Ionic Zip Library v1.9.1.6 BufferSize Property
ReferenceIonic.ZipZipFileBufferSize
Size of the IO buffer used while saving.
Declaration Syntax
C# Visual Basic Visual C++
public int BufferSize { get; set; }
Public Property BufferSize As Integer
	Get
	Set
public:
property int BufferSize {
	int get ();
	void set (int value);
}
Remarks

First, let me say that you really don't need to bother with this. It is here to allow for optimizations that you probably won't make! It will work fine if you don't set or get this property at all. Ok?

Now that we have that out of the way, the fine print: This property affects the size of the buffer that is used for I/O for each entry contained in the zip file. When a file is read in to be compressed, it uses a buffer given by the size here. When you update a zip file, the data for unmodified entries is copied from the first zip file to the other, through a buffer given by the size here.

Changing the buffer size affects a few things: first, for larger buffer sizes, the memory used by the ZipFile, obviously, will be larger during I/O operations. This may make operations faster for very much larger files. Last, for any given entry, when you use a larger buffer there will be fewer progress events during I/O operations, because there's one progress event generated for each time the buffer is filled and then emptied.

The default buffer size is 8k. Increasing the buffer size may speed things up as you compress larger files. But there are no hard-and-fast rules here, eh? You won't know til you test it. And there will be a limit where ever larger buffers actually slow things down. So as I said in the beginning, it's probably best if you don't set or get this property at all.

Examples
This example shows how you might set a large buffer size for efficiency when dealing with zip entries that are larger than 1gb.
CopyC#
using (ZipFile zip = new ZipFile())
{
    zip.SaveProgress += this.zip1_SaveProgress;
    zip.AddDirectory(directoryToZip, "");
    zip.UseZip64WhenSaving = Zip64Option.Always;
    zip.BufferSize = 65536*8; // 65536 * 8 = 512k
    zip.Save(ZipFileToCreate);
}

Assembly: Ionic.Zip (Module: Ionic.Zip) Version: 1.9.1.8 (1.9.1.8)