Compress a file to .zip?

Posted on 2002-03-07
Last Modified: 2008-02-01
How do I compress a file to .zip in a vb-project.
Is there a way to do this for free. I have searched the web and found a couple that costed money.
Question by:ajohans
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 6846740

Here's a file for you over the net:

Description: A powerful and very quick compression program using the 32bit zlib.dll (V1.1.3) compression library originally written by Jean-loup Gailly and Mark Adler (variation of LZ77 Lempel-Ziv 1977 algoritm). The application is implemented through an extensive ArielZip class and a Winzip like client interface. Features * Powerful and very fast - compresses 6000 kb data files to 1500 kb (25%) in 2.1 seconds! * Multiple disk spanning with automatic sensing of disk capacity * User friendly floppy disk change dialogue showing contents of disk to be overwritten * Single and multiple file extraction * Extracted icons included in archive as bitmaps * 9 compression levels * Add folders and subfolders through recursive scanning of FSO objects * Add files  

Description: ZLIB is a compression library compatible with the gzip format

That's it!

glass cookie : )
LVL 52

Expert Comment

by:Ryan Chong
ID: 6846742

Expert Comment

ID: 6846753
Hi ajohans,
Check the URL posted above, you´ll find a very useful project made by a pal programmer that will teach you the good way of using the FREE zlib.dll zipping library. 

Hope this works
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.


Author Comment

ID: 6846771
Does this project compress the files in .zip so that somebody can unpack it in winzip later?

Author Comment

ID: 6846799
Does this project compress the files in .zip so that somebody can unpack it in winzip later?

Author Comment

ID: 6846837
Does this project compress the files in .zip so that somebody can unpack it in winzip later?

Expert Comment

ID: 6846866
This guy did wrote a custom headers to his zipped documents. I thought you wanted to create the same type of applications. For what you want, may be you can do it with the following code

Function winZipit(ByVal source As String, ByVal target As String, ByVal zip As Boolean)
    zipIT = App.Path & "winzip32 -a"
    unzipIT = App.Path & "winzip32 -e "

    If zip = True Then
        Shell (zipIT & target & source)
    Else: Shell (unzipIT & target & source)
    End If
End Function

Expert Comment

ID: 6846868
sorry, i forgot to tell you, the code i did submitted is to work with Winzip program.....

Expert Comment

ID: 6846873
to work with Winzip to zip unzip:

Adding files:
The command format is:
winzip[32].exe [-min] action [options] filename[.zip] files
-min specifies that WinZip should run minimized. If -min is specified,
it must be the first command line parameter.
-a For add, -f for freshen, -u for update, and -m for move. These
actions correspond To the actions described In the section titled
"Adding files To an Archive" in the online manual.
-r and -p correspond To the "Recurse Directories" and "Save Extra
Directory Info" checkboxes in the Add and Drop dialog boxes. -ex, -en,
-ef, -es, and -e0 options determine the compression method: eXtra,
Normal, Fast, Super fast, and no compression. The default is "Normal".
-s allows specification of a password. The password can be enclosed
In quotes, For example, -s"Secret Password". Note that passwords are
-hs option allows hidden and system files To be included.
Specifies the name of the ZIP involved. Be sure To use the full
filename (including the directory).
Is a list of one or more files, or the @ character followed by the
filename containing a list of files To add, one filename per line.
Wildcards (e.g. *.bak) are allowed.
Extracting Files:
The command format is:
winzip[32].exe -e [options] filename[.zip] directory
-e Is required.
-o and -j stand For "Overwrite existing files without prompting" and
"Junk pathnames", respectively. Unless -j is specified, directory
information is used.
-s allows specification of a password. The password can be enclosed
In quotes, For example, -s"Secret Password". Note that passwords are
Specifies the name of the ZIP involved. Be sure To specify the full
filename (including the directory).
Is the name of the directory to which the files are extracted. If the
directory does Not exist it is created.

* VERY IMPORTANT: Always specify complete filenames, including the full
path name and drive letter, For all file IDs.
* To run WinZip in a minimized inactive icon use the "-min" option.
When specified this option must be the first option.
* Only operations involving the built-in zip and unzip are supported.
* Enclose Long filenames on the command line in quotes.
* NO leading or trailing blanks, or blank lines For readability, are
allowed In list ("@") files.
* The action and Each option on the command line must be separated
from the others by at least one space.
* WinZip can be used To compress files With cc:Mail . Change the
compress= line in the [cc:Mail] section of the appropriate WMAIL.INI
files To specify the full path For WinZip followed by "-a %1 @%2".

For example, If WinZip is installed in your c:\winzip directory,
    compress=c:\winzip\winzip.exe -a %1 @%2


Author Comment

ID: 6846992
Thank you for the tip.
I have tried that but I can't get it to work.
I am going to monitor a directory and when a .xml-file appears i am going to create a md5-file from that xml-file and then zip these two files together.
All goes fine until I am going to zip them together.
Sometimes it goes OK for one file but when another zipfile is going to be created the following error appears:

Action: Add (and replace) files Include subfolders: yes Save full path: no
Adding penfile_100_1011344423242_16.md5
Warning: could not open for reading: e:\Project\Anoto\xml-files\penfile_100_1011344423242_16.md5
replacing old Zip file

And the md5-file does not get compressed. My code is as follows:

target = """" & path & "\" & Mid(FileName, 1, (Len
         (FileName) - 3)) & "zip"""

sourceXML = """" & path & "\" & FileName & """"

sourcemd5 = """" & path & "\" & ChecksumFile & """"

winzipstring = WinzipPath & " -min -a " & target & " " &

Shell (winzipstring)
winzipstring = WinzipPath & " -min -a " & target & " " &
Shell (winzipstring)

Am I doing something wrong?

Accepted Solution

tonydspaniard earned 100 total points
ID: 6847078
I found something even better:

Here is your OCX and say thank you to the guy. It is free and the zip files will be able to be opened by Winzip

Its web site is this one.

But is the OCX that interest you

Take care..... forget about the other stuff. It seems that Winzip does have troubles with path names with spaces.....

Good talking to you. I know this will resolve your problem


Author Comment

ID: 6847191
Absolutely amazing.
Thank you VERY MUCH!!

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question