InitializeDeflate Method

DotNetZip

Ionic Zip Library v1.9.1.6 InitializeDeflate Method
ReferenceIonic.ZlibZlibCodecInitializeDeflate()()()()
Initialize the ZlibCodec for deflation operation.
Declaration Syntax
C# Visual Basic Visual C++
public int InitializeDeflate()
Public Function InitializeDeflate As Integer
public:
int InitializeDeflate()
Return Value
Z_OK if all goes well. You generally don't need to check the return code.
Remarks
The codec will use the MAX window bits and the default level of compression.
Examples
CopyC#
int bufferSize = 40000;
byte[] CompressedBytes = new byte[bufferSize];
byte[] DecompressedBytes = new byte[bufferSize];

ZlibCodec compressor = new ZlibCodec();

compressor.InitializeDeflate(CompressionLevel.Default);

compressor.InputBuffer = System.Text.ASCIIEncoding.ASCII.GetBytes(TextToCompress);
compressor.NextIn = 0;
compressor.AvailableBytesIn = compressor.InputBuffer.Length;

compressor.OutputBuffer = CompressedBytes;
compressor.NextOut = 0;
compressor.AvailableBytesOut = CompressedBytes.Length;

while (compressor.TotalBytesIn != TextToCompress.Length && compressor.TotalBytesOut < bufferSize)
{
  compressor.Deflate(FlushType.None);
}

while (true)
{
  int rc= compressor.Deflate(FlushType.Finish);
  if (rc == ZlibConstants.Z_STREAM_END) break;
}

compressor.EndDeflate();

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