Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 599
  • Last Modified:

Compress a file to .zip?

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.
0
ajohans
Asked:
ajohans
1 Solution
 
glass_cookieCommented:
Hi!

Here's a file for you over the net:

Download...
http://www.vbdiamond.com/Sources/DownloadFile.asp?ID=2139
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  
...

Download...
http://www.gzip.org/zlib.zip
Description: ZLIB is a compression library compatible with the gzip format

That's it!

glass cookie : )
0
 
tonydspaniardCommented:
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.

http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=14087&lngWId=1 


Hope this works
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
ajohansAuthor Commented:
Does this project compress the files in .zip so that somebody can unpack it in winzip later?
0
 
ajohansAuthor Commented:
Does this project compress the files in .zip so that somebody can unpack it in winzip later?
0
 
ajohansAuthor Commented:
Does this project compress the files in .zip so that somebody can unpack it in winzip later?
0
 
tonydspaniardCommented:
ajohans:
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
0
 
tonydspaniardCommented:
sorry, i forgot to tell you, the code i did submitted is to work with Winzip program.....
0
 
tonydspaniardCommented:
to work with Winzip to zip unzip:


Adding files:
The command format is:
winzip[32].exe [-min] action [options] filename[.zip] files
where:
-min specifies that WinZip should run minimized. If -min is specified,
it must be the first command line parameter.
action
-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.
options
-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
case-sensitive.
-hs option allows hidden and system files To be included.
filename.zip
Specifies the name of the ZIP involved. Be sure To use the full
filename (including the directory).
files
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
where:
-e Is required.
options
-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
case-sensitive.
filename.zip
Specifies the name of the ZIP involved. Be sure To specify the full
filename (including the directory).
directory
Is the name of the directory to which the files are extracted. If the
directory does Not exist it is created.


Notes:
* 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,
    specify
    compress=c:\winzip\winzip.exe -a %1 @%2

0
 
ajohansAuthor Commented:
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 & " " &
               sourceXML

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

Am I doing something wrong?
0
 
tonydspaniardCommented:
I found something even better:

http://www.btinternet.com/~richsoftcomputing/VBZip.zip

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.

http://www.richsoftcomputing.btinternet.co.uk/html/vbzip.html

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

0
 
ajohansAuthor Commented:
Absolutely amazing.
Fantastic!
Thank you VERY MUCH!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now