Click here to Skip to main content
13,191,642 members (69,104 online)
Click here to Skip to main content
Add your own
alternative version


58 bookmarked
Posted 2 Jan 2001

SAWZip - zip file manipulation control

, 29 Aug 2001
Rate this:
Please Sign up or sign in to vote.
An ATL based control for reading and writing zip files.


While I was developing my Java Class Browser (JCB) I needed a control or sourcecode (C++) to read jar-files. I searched the web and I didn't find any good freeware to resolve this problem. What I found was the zlib-compression library of Jean-loup Gailly and Mark Adler. It was not easy to figure it out how it worked. After a while I found the library written by Tadeusz Dracz. He uses the zlib-compression in a MFC library. It gave me a good idea on how to use the zlib-compression library. The problem with his library was that it was written with MFC, and I want to avoid using MFC because I JCB is a WTL-program. That's why I started to develop an ATL-control based on the code I found in the sourcecode of Tadeusz Dracz.

You can use this control with Visual C++ and Visual Basic 6.0. The control has been tested on Windows 98 and Windows NT. The UNICODE version of the application is not yet tested on a Windows NT Platform.

Archive Object


NameStringRThe name of the zipfile.
FilesFiles ObjectRA collection of file-objects.
CommentStringR/WThe comment for the zipfile.
ReadOnly Boolean RTrue when the zip you opened is read-only. Test on this flag before you want to compress some files.


Close//Closes the zipfile.
Create/ByVal aName as StringThe name of the zipfile to create
Open/ByVal aName as StringThe name of the zipfile to open

Files Object


CountlongRNumber of files in the archive.


Add/ByVal newVal as FileAdds a file to the archive. When there's already a file compressed with the same name it will be override this file.
AddFileByName/ByVal aName as String,
ByVal level as Integer,
ByVal fullPath as Boolean,
ByVal refresh as Boolean
This method can add files with wildcards. For level and fullPath see File Object for more information. When refresh is set to true, the file with the same name in the archive is overwritten. When it is set to false, the file will be skipped.

The following example does the following: Adding all C++ sources in the current-directory to the archive. Overwrite the current files in the archive.
zip.Files.AddFileByName "*.cpp", 1, true, true
ItemFileByVal index as LongReturns the file on position index.
Remove/ByVal index as LongRemoves the file with position index from the archive.

File Object


NameStringR/WThe name of the file. When added with fullPath set to false, the path will not be stored in the archive.
DirectoryBooleanRReturns true when the file is a directory.
CompressedSizeLongRThe size of the file when compressed.
UncompressedSizeLongRThe size of the file when not compressed.
LevelIntegerR/WThe level used to perform compression. A value in the range of 0 - 9. 0 is no compression at all. 1 gives best speed, 9 gives best compression. This can only be set when the file is not yet stored in the archive.
Crc32LongRReturns the crc checkum value.
CommentStringR/WReturns or sets the comment. The comment can only be set when the file is not yet in stored in the archive.
FullPathBooleanR/WWhen stored to the archive and FullPath is false the path-information will be discarded. When the file is extracted and the FullPath is false the file will be extracted without the path-information.
IndexLongRThe index of this file object in the Files collection. This will be -1 when the file is not yet stored in the archive.


Extract/ByVal aPath as StringExtract the file into the specified path. When FullPath is set to false, the file will be stored without the path-information.


This control uses the dll-version of the zlib-compression library. When you install this control the zlib.dll must be reachable. This control makes heavy use of private interfaces to communicate between the different objects. You can read more about this on my page of SAWEditListCtrl on how to accomplish this.


Here is a list of resources I used to develop this control:

The MFC Library of Tadeusz Dracz.
The zlib-compression home page.


27-Dec-2000    Version 1.0 Released.

8-Mar-2001    Version 1.1

  1. Add properties to the fileobject to retrieve the dates of the files
  2. Extracting to a stringbuffer

18-Apr-2001    Version 1.2

  1. Solved a bug in AddFileByName.

23-May-2001    Version 1.4

  • Added a new property for testing on readonly zip-files. Now you can extract from a file from readonly-files.
  • Resolved a memory-leak after extracting a file. (Thanks go to Brad Gutilla).

28-Jun-2001    Version 1.6

  • Version 1.6: Bug resolved in the extract-method. When fullpath was true and the directory didn't exist a Can't create file occured. Now the fullpath is created before extracting. (Thanks Nat Dickinson)

30-Aug-2001 Version 2.0

  • Version 2.0: Solved the comment-bug on the archive-object. Compatible for Win95-users. (Thanks to Frederic St-Laurent)


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Franky Braem
Web Developer
Belgium Belgium
Programmer since 1991 using C/C++/Visual Basic and Java. Playing with wxWindows at home.

You may also be interested in...

Comments and Discussions

GeneralLatest version Pin
Michael Ouellette19-Jul-09 17:06
memberMichael Ouellette19-Jul-09 17:06 
Generalrequired bugfix ... Pin
peeveen11-Apr-07 3:41
memberpeeveen11-Apr-07 3:41 
GeneralIt is not working Pin
selfay19-Feb-06 21:43
memberselfay19-Feb-06 21:43 
Questionhow to implement ExtractToStream using ASP Pin
bersileus20-Dec-04 19:41
memberbersileus20-Dec-04 19:41 
Generalerror: start of central directory not found Pin
marcbelcourt5-Nov-04 10:28
sussmarcbelcourt5-Nov-04 10:28 
GeneralRe: error: start of central directory not found Pin
Anonymous13-Oct-05 8:34
sussAnonymous13-Oct-05 8:34 
QuestionCAB format compression? Pin
dragomir17-Feb-04 22:13
memberdragomir17-Feb-04 22:13 
GeneralNice Component, but ....... Pin
Mr.Prakash21-Jan-04 0:58
memberMr.Prakash21-Jan-04 0:58 
QuestionMulti-volume support? Pin
petand787-Aug-03 6:09
memberpetand787-Aug-03 6:09 
AnswerRe: Multi-volume support? Pin
petand787-Aug-03 6:13
memberpetand787-Aug-03 6:13 
GeneralError in : ZIP.OPEN "\\SERVER\TEST\TEST.ZIP" Pin
Manaophe5-Dec-02 23:05
memberManaophe5-Dec-02 23:05 
Generalbuild bugs on w2k Pin
Scott Cameron19-Sep-02 8:23
sussScott Cameron19-Sep-02 8:23 
GeneralRe: build bugs on w2k Pin
Anonymous20-Sep-02 5:45
sussAnonymous20-Sep-02 5:45 
GeneralRe: build bugs on w2k Pin
Anonymous20-Sep-02 6:16
sussAnonymous20-Sep-02 6:16 
GeneralRe: build bugs on w2k Pin
Anonymous20-Sep-02 6:32
sussAnonymous20-Sep-02 6:32 
GeneralRe: build bugs on w2k Pin
Franky Braem20-Sep-02 9:56
memberFranky Braem20-Sep-02 9:56 
GeneralRe: build bugs on w2k Pin
Anonymous15-Oct-02 4:38
sussAnonymous15-Oct-02 4:38 
GeneralSAWZip 2.6 Pin
Franky Braem14-Sep-02 2:44
memberFranky Braem14-Sep-02 2:44 
GeneralRe: SAWZip 2.6 Pin
Member 735101724-Oct-11 0:45
memberMember 735101724-Oct-11 0:45 
Dear Franky Braem,

I am using SawZip.dll and I want add whole directory and subdirectory into a zip file but version 2.0 is not supported. I visit your website but I don't see any where to download version 2.6. Could you send it to me by email or give me a directly link to get it.My email is Thanks a lot.
QuestionIs there a way to add whole directory using AddFileByName ? Pin
mchan20-Aug-02 12:37
membermchan20-Aug-02 12:37 
AnswerRe: Is there a way to add whole directory using AddFileByName ? Pin
mchan21-Aug-02 17:37
membermchan21-Aug-02 17:37 
GeneralRe: Is there a way to add whole directory using AddFileByName? /// Relative path Pin
agyklon13-Sep-02 8:54
sussagyklon13-Sep-02 8:54 
GeneralRe: Is there a way to add whole directory using AddFileByName? /// Relative path Pin
Franky Braem14-Sep-02 2:41
memberFranky Braem14-Sep-02 2:41 
GeneralRe: Is there a way to add whole directory using AddFileByName? /// Relative path Pin
Anonymous15-Sep-02 9:48
sussAnonymous15-Sep-02 9:48 
GeneralSawZip Pin
Nick Davison25-Jul-02 3:17
sussNick Davison25-Jul-02 3:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171017.2 | Last Updated 30 Aug 2001
Article Copyright 2001 by Franky Braem
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid