Aug
28
2003

Zip Extraction Class

Extract Zip archives using the ZLib.dll

Well I've finally put the Zip Extraction Class together. It's got a very simple and somewhat limited interface. Limitations include having to extract all the files in a zip archive and not setting the extracted file's Modify Date to its Modify Date in the archive.

If you declare the ZipExtractionClass in the declerations area of a Class Module or Form using the WithEvents keyword then you gain access to the Status, Progress and Error Events.

Usage

Add ZipExtractionClass.cls to your project and ensure that zlib.dll is reachable

Option Explicit

Private WithEvents zip As ZipExtractionClass

Public sub Unzip

   Set zip = New ZipExtractionClass
   If zip.OpenZip("C:\Test\Test.zip") Then
      If zip.Extract("C:Test\Extract", True, True) Then
         MsgBox "Zip files extracted successfully", vbInformation
      End If
      zip.CloseZip
   End If
   Set zip = Nothing

End Sub

Downloads

  ZipExtractionClass.zip - contains: ZipExtractionClass.cls, Appnote.txt, ZLib.dll (45.0 kb)

  ZipProject.zip - contains: A sample project using the ZipExtractionClass (60 kb)

Links

The ZLib home page where you'll find the ZLib.dll: www.zlib.org

The PKZip File Format: www.pkware.com

More...

Jun
28
2002

Zip Class

PKZip compatible Zip files using the ZLib.dll

A big thanks to Jean-loup Gailly and Mark Adler for their ZLib compression/decompression Library (you'll need it if you want to use this code, download it from the links at the bottom of the page - best to copy the dll into your system directory). I've put it to good use with my classes for writing PKZip compatible files in Visual Basic. I'm not a big fan of in-line documentation (it just gets in the way) so I hope you can follow it. There's two classes (ZipClass and ZipFile). ZipFile should be a private class, it handles all the nasty stuff.

I intend to expand the code to read Zip files at some stage when I get the time but don't hold your breath.

What it can do

  • Write Zip files in a PKZip compatible format

What it can't do (yet?)

  • Span multiple disks
  • Read Zip Files

Usage

Add ZipClass.cls and ZipFile.cls to your project and ensure that zlib.dll is reachable

   Dim z As ZipClass

   Set z = New ZipClass

   z.AddFile "c:\test.doc"
   z.AddFile "c:\test.jpg"
   z.WriteZip "c:\test.zip", True

   Set z = Nothing

Downloads

  ZipClass.zip - contains: ZipClass.cls, ZipFile.cls, Appnote.txt, zlib.dll (45.3 kb)

Links

The ZLib home page where you'll find the ZLib.dll: www.zlib.org

The PKZip File Format: www.pkware.com

More...