Sample code for 30+ languages & platforms
Delphi ActiveX

Unzip Files to Byte Array

See more Zip Examples

Demonstrates how to unzip each file contained in a .zip to an in-memory byte array.

Chilkat Delphi ActiveX Downloads

Delphi ActiveX
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Integer;
zip: TChilkatZip;
numEntries: Integer;
entry: TChilkatZipEntry;
i: Integer;
fileData: Array of Byte;

begin
success := 0;

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

zip := TChilkatZip.Create(Self);

success := zip.OpenZip('qa_data/zips/test.zip');
if (success = 0) then
  begin
    Memo1.Lines.Add(zip.LastErrorText);
    Exit;
  end;

// Iterate of each entry in the zip.
// An entry can be a file or directory entry.  For each file, unzip to a byte array.
numEntries := zip.NumEntries;
Memo1.Lines.Add('NumEntries = ' + IntToStr(numEntries));

entry := TChilkatZipEntry.Create(Self);
i := 0;
while i < numEntries do
  begin
    zip.EntryAt(i,entry.ControlInterface);
    if (entry.IsDirectory = 0) then
      begin
        fileData := entry.Inflate();
        // Do whatever you wish with the file data...
      end;
    i := i + 1;
  end;

zip.CloseZip();

Memo1.Lines.Add('Finished.');
end;