Xceed Zip Compression Library Documentation
Listing the contents of a zip file
Getting started quickly > Listing the contents of a zip file

Xceed Zip Compression Library can list the contents of a zip file either by triggering an event for each file that provides the file's name and other information, or by providing you with the complete listing (filenames and other information) in a collection object. Listing by event is easier and takes less memory, but is not always possible or useful. Listing by obtaining a collection object is slightly faster and allows you to enumerate the collection as often as you need without re-listing the zip file. See the Listing by collection getting started quickly topic if you are interested in the latter technique.

Basic listing by event

To list the contents of a zip file, perform the following 4 steps. Put the Xceed Zip control on a form, add a listbox to the form (if you want to display the list files in a listbox) and then:

Here is sample VB code for these 4 steps (excluding the code for the ListingFile event):

Visual Basic  

' Don't forget to put an Xceed Zip control on a form
Dim ResultCode As xcdError
Call XceedZip1.License( "your license key" )

XceedZip1.ZipFilename = "c:\backups\My documents.zip"
ResultCode = XceedZip1.ListZipContents
If ResultCode = xerSuccess then
MsgBox "Files listed successfully."
Else
MsgBox XceedZip1.GetErrorDescription(xvtError, ResultCode)
EndIf
You will also need to put the following code into the ListingFile event handler. This code assumes you want to put the listed items in a listbox, and display only the filename and size:
ListBox1.AddItem sFilename + " size=" + Str(lCompressedSize)

Here is sample Delphi code for these 4 steps (excluding the code for the ListingFile event):

Delphi  

var xErr : xcdError;
begin
XceedZip1.License( 'your license key' );

XceedZip1.ZipFilename := 'c:\backups\My documents.zip';

xErr := XceedZip1.ListZipContents;

ShowMessage( XceedZip1.GetErrorDescription( xvtError, xErr ) );
end;

You will also need to put the following code into the ListingFile event handler. This code assumes you want to put the listed items in a listbox, and display only the filename and size:

Delphi  

ListBox1.Items.Add( sFilename + ' size=' + IntToStr( lCompressedSize ) );

Things you should consider

The main questions you should ask yourself when listing files are:

Other questions you may want to consider are:

If there's anything else you need to do that's not mentioned here, consult the Properties topic, or search the index – chances are, Xceed Zip does what you need. If not, ask Xceed Software whether it is possible or not.