Xceed Zip for COM/ActiveX on x86/x64 Documentation
Getting started quickly / Listing the contents of a zip file (by collection)
In This Topic
    Listing the contents of a zip file (by collection)
    In This Topic

    VB example Delphi example VC++ example C# example VB.NET example

    Introduction

    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 (file names 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 event getting started quickly topic if you are interested in the former technique. 

    Basic listing by collection

    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:

    • Specify the zip file to list the contents of. To do this, set the ZipFilename property.

    • Obtain the collection. Call the GetZipContents method to get an XceedZipItems collection.

    • Make sure it worked successfully. To do this, check the GetZipContents method's return value.

    • Enumerate the items in the collection. Use either the collection object's Item and Count properties, or your language's built-in support for collection objects. Each item in the collection is an object of type XceedZipItem  

    Things you should consider 

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

    • What information do you need? The XceedZipItem object plenty of properties containing not only the file's path and filename, but plenty of other file information.

    • Are you possibly listing a spanned zip file? If so, write a handler for the InsertDisk event.

    • Do you want to display the status of the listing operation? See the GlobalStatus event. 

    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.