SetCompression Property

DotNetZip

Ionic Zip Library v1.9.1.6 SetCompression Property
ReferenceIonic.ZipZipFileSetCompression
A callback that allows the application to specify the compression level to use for entries subsequently added to the zip archive.
Declaration Syntax
C# Visual Basic Visual C++
public SetCompressionCallback SetCompression { get; set; }
Public Property SetCompression As SetCompressionCallback
	Get
	Set
public:
property SetCompressionCallback^ SetCompression {
	SetCompressionCallback^ get ();
	void set (SetCompressionCallback^ value);
}
Remarks

With this callback, the DotNetZip library allows the application to determine whether compression will be used, at the time of the Save. This may be useful if the application wants to favor speed over size, and wants to defer the decision until the time of Save.

Typically applications set the CompressionLevel property on the ZipFile or on each ZipEntry to determine the level of compression used. This is done at the time the entry is added to the ZipFile. Setting the property to Ionic.Zlib.CompressionLevel.None means no compression will be used.

This callback allows the application to defer the decision on the CompressionLevel to use, until the time of the call to ZipFile.Save(). The callback is invoked once per ZipEntry, at the time the data for the entry is being written out as part of a Save() operation. The application can use whatever criteria it likes in determining the level to return. For example, an application may wish that no .mp3 files should be compressed, because they are already compressed and the extra compression is not worth the CPU time incurred, and so can return None for all .mp3 entries.

The library determines whether compression will be attempted for an entry this way: If the entry is a zero length file, or a directory, no compression is used. Otherwise, if this callback is set, it is invoked and the CompressionLevel is set to the return value. If this callback has not been set, then the previously set value for CompressionLevel is used.

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