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...