Free Zip component

The XHTML WYSIWYG Editor For Desktop & Web Applications

Zip Component

Overview

The Zip component provides industry-standard Zip archive functionality. It is designed to be easy to use. You can pack/unpack a file or folder with a single line of code. If you need to create or extract Zip files on the fly, this component is for you. This component can be used in environments that support COM such as Active Server Pages, Windows Scripting Host, Visual Basic, etc.

License
Freeware
Type
32-bit ActiveX DLL
Version
2.5
File Name
XZip.dll
Download Package
x-zip.zip

Download

Download Zip Component

Visual C++ users can download header files.

Installation Instructions

  1. Move the dll to a directory like: C:\Program Files\XStandard\Bin\.
  2. Open a command prompt and cd to the directory where the dll is located.
  3. Type regsvr32 XZip.dll or on 64-bit OS type C:\Windows\SysWOW64\regsvr32.exe XZip.dll
  4. Grant "Read & Execute" file permissions on this dll to Everyone.

Note, the command prompt must be "Run as administrator" as shown in the screen shot below.

Context menu for the command prompt showing the option to run as administrator.

Uninstall Instructions

  1. Open a command prompt and cd to the directory where the dll is located.
  2. Type regsvr32 -u XZip.dll or on 64-bit OS type C:\Windows\SysWOW64\regsvr32.exe -u XZip.dll

Usage from 64-bit OS

Please see instructions for 64-bit OS usage.

API Reference: ProgID: XStandard.Zip

Sub Pack(sFilePath As String, sArchive As String, [bStorePath As Boolean = False], [sNewPath As String], [lCompressionLevel As Long = -1])

Add file or folder to an archive. Compression level 1 is minimum, level 9 is maximum, all other values default to level 6.

Sub UnPack(sArchive As String, sFolderPath As String, [sPattern As String])

Extract contents of an archive to a folder.

Sub Delete(sFile As String, sArchive As String)

Remove a file from an archive.

Sub Move(sFrom As String, sTo As String, sArchive As String)

Move or rename a file in the archive.

Function Contents(sArchive As String) As Items

Get a list of files and folder in the archive.

Property ErrorCode As Long

(read-only)
Return the code of last operation. The following are possible error codes:

Error codeDescription
200Archive file is not correct.
201Archive file is not a valid zip file[header].
202Archive file is not a valid zip file[dir].
203Cannot create archive file.
204Compressed header is not correct
205File size is not correct.
206Cannot Alloc memory
207Cannot open archive file
208Archive file is empty
209Cannot alloc memeory.
210Cannot find source file.
211Cannot open file
212Cannot alloc memory.
213Cannot alloc memory.
214There is no file.
215Archive file is same as the input file.
216Cannot Alloc memory.
217Incorrect signature of header
230Cannot open archive file.
240Archive file is not correct.
241Archive file is not a valid zip file[header].
242Archive file is not a valid zip file[dir].
250Cannot open archive file.
251Archive file is not correct.
252Cannot create file for swapping.
253Header of archive file is incorrect.
254Unknown error when modifying archive file.
290Cannot get information from archive file.
291Cannot get information from archive file.
591Cannot get information from archive file.

Property ErrorDescription As String

(read-only)
Return the error code description of last operation.

Property Version As String

(read-only)
Product version.

API Reference: Class: Items

Property Count As Long

(read-only)
Returns the number of members in a collection.

Property Item(Index As Long) As Item

(read-only)
Returns a specific member of a collection by position.

API Reference: Class: Item

Property Date As Date

(read-only)
Last modified date.

Property Name As String

(read-only)
File name.

Property Path As String

(read-only)
Relative path.

Property Size As Long

(read-only)
File size in bytes.

Property Type As ItemType

(read-only)
Type of object.

API Reference: Enum: ItemType

Const tFolder = 1

Item is a folder.

Const tFile = 2

Item is a file.

Examples

The examples below are for Active Server Pages. For Windows Scripting Host or Visual Basic, replace Server.CreateObject with CreateObject and replace Resonse.Write with MsgBox.

How to archive (or zip) multiple files

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.Pack "C:\Temp\golf.jpg", "C:\Temp\images.zip"
  5. objZip.Pack "C:\Temp\racing.gif", "C:\Temp\images.zip"
  6. Set objZip = Nothing
  7. %>

How to archive (or zip) multiple files with different compression levels

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.Pack "C:\Temp\reports.doc", "C:\Temp\archive.zip", , , 9
  5. objZip.Pack "C:\Temp\boat.jpg", "C:\Temp\archive.zip", , , 1
  6. Set objZip = Nothing
  7. %>

How to archive (or zip) multiple files with default path

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.Pack "C:\Temp\reports.doc", "C:\Temp\archive.zip", True
  5. objZip.Pack "C:\Temp\boat.jpg", "C:\Temp\archive.zip", True
  6. Set objZip = Nothing
  7. %>

How to archive (or zip) multiple files with a custom path

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.Pack "C:\Temp\reports.doc", "C:\Temp\archive.zip", True, "files/word"
  5. objZip.Pack "C:\Temp\boat.jpg", "C:\Temp\archive.zip", True, "files/images"
  6. Set objZip = Nothing
  7. %>

How to archive (or zip) multiple files using wildcards

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.Pack "C:\Temp\*.jpg", "C:\Temp\images.zip"
  5. Set objZip = Nothing
  6. %>

How to unzip files

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.UnPack "C:\Temp\images.zip", "C:\Temp\"
  5. Set objZip = Nothing
  6. %>

How to unzip files using wildcards

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.UnPack "C:\Temp\images.zip", "C:\Temp\", "*.jpg"
  5. Set objZip = Nothing
  6. %>

How to get a listing of files and folder in an archive

  1. <%
  2. Dim objZip, objItem
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. For Each objItem In objZip.Contents("C:\Temp\images.zip")
  5. Response.Write objItem.Path & objItem.Name & "<br />"
  6. Next
  7. Set objZip = Nothing
  8. Set objItem = Nothing
  9. %>

How to remove a file from an archive

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.Delete "headshots/smith.jpg", "C:\Temp\images.zip"
  5. Set objZip = Nothing
  6. %>

How to move a file in an archive

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.Move "headshots/jones.jpg", "staff/jones.jpg", "C:\Temp\images.zip"
  5. Set objZip = Nothing
  6. %>

How to rename a file in an archive

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.Move "headshots/jones.jpg", "headshots/randy-jones.jpg", "C:\Temp\images.zip"
  5. Set objZip = Nothing
  6. %>

Known Issues

  • The UnPack() method will first remove all files from the destination folder. This behavior will change in future releases.
  • This component was not designed to work with huge archives. Max archive size depends on the amount of available RAM.
  • This component is designed for 32-bit operating systems and will not work natively on 64-bit operating systems.