Zip for VB.Net? [Resolved]
Hi there,
I have been looking for a way to zip files and directories up within vb.net.
I have heard of the CdSharp open source libraries but have been unable to get it to work. I have also heard of Xceed Zip class but that cost alot for something simple which i need to get done.
Has anyone got the zip to work? Can i make use of the in build zip in winXP?
Cheers
Re: Zip for VB.Net? [Resolved]
Re: Zip for VB.Net? [Resolved]
Yes, that is the same code in 2003.
Re: Zip for VB.Net? [Resolved]
rgr
What is the DatabasePath variable?
Re: Zip for VB.Net? [Resolved]
That is the name of the file to zip I'd assume. Just check the commandline arguments of the WZZIP.EXE by typing at the command prompt "WZZIP.EXE /?"
Re: Zip for VB.Net? [Resolved]
Quote:
Originally Posted by RobDog888
That is the name of the file to zip I'd assume. Just check the commandline arguments of the WZZIP.EXE by typing at the command prompt "WZZIP.EXE /?"
Not sure what you mean by that.
I found this
Quote:
Adding Files
"The command format is:
winzip32 [-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. You must specify one (and only one) of these actions. The actions correspond to the actions described in the section titled "Add dialog box options" in the online manual.
options
-r corresponds to the Include subfolders checkbox in the Add dialog and causes WinZip to add files from subfolders. Folder information is stored for files added from subfolders. If you add -p, WinZip will store folder information for all files added, not just for files from subfolders; the folder information will begin with the folder specified on the command line.
-ex, -en, -ef, -es, and -e0 determine the compression method: eXtra, Normal, Fast, Super fast, and no compression. The default is "Normal". -hs includes hidden and system files. Use -sPassword to specify a case-sensitive password. The password can be enclosed in quotes, for example, -s"Secret Password".
filename.zip
Specifies the name of the Zip file involved. Be sure to use the full filename (including the folder).
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.
They way i followed it dosn't seem to work correctly
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Process.Start("C:\Program Files\WinZip\WZZIP.EXE", "-rp C:\Documents and Settings\toe\Desktop\WinZip\Document.zip" & "Document.txt")
End Sub
Error:
"System cannot find the find the file specified"
While trying to zip this file
("C:\Documents and Settings\toe\Desktop\WinZip\Document.txt")
Can you see what iam doing wrong?
thanks
toe
Re: Zip for VB.Net? [Resolved]
mmmm, maybe it only works with the pro version
Quote:
The WinZip Command Line Support Add-On is a FREE add-on for users of WinZip Pro with a valid license.
winzip.com
Re: Zip for VB.Net? [Resolved]
As I stated in my post a few years ago, if you are trying to Zip from .Net, you can use the #Ziplib library. It is free.
http://www.icsharpcode.net/OpenSource/SharpZipLib/
Re: Zip for VB.Net? [Resolved]
This code will zip a folder of files using WinXP built in compression:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim srcfolderString As String
Dim dstfolderString As String = "c:\ZippedFolder.zip"
'get folder to zip
Dim fbd As New FolderBrowserDialog
If fbd.ShowDialog() = Windows.Forms.DialogResult.OK Then
srcfolderString = fbd.SelectedPath
'create empty zip file
Dim fileContents() As Byte = {80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
My.Computer.FileSystem.WriteAllBytes(dstfolderString, fileContents, False)
Dim objShell As New Shell32.ShellClass
Dim objFolderSrc As Shell32.Folder
Dim objFolderDst As Shell32.Folder
Dim objFolderItems As Shell32.FolderItems
objFolderSrc = objShell.NameSpace(srcfolderString)
objFolderDst = objShell.NameSpace(dstfolderString)
objFolderItems = objFolderSrc.Items
objFolderDst.CopyHere(objFolderItems, 20)
End If
You also need to add a reference to Microsoft Shell Controls And Automation
Re: Zip for VB.Net? [Resolved]
Quote:
Originally Posted by nbrege
This code will zip a folder of files using WinXP built in compression:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim srcfolderString As String
Dim dstfolderString As String = "c:\ZippedFolder.zip"
'get folder to zip
Dim fbd As New FolderBrowserDialog
If fbd.ShowDialog() = Windows.Forms.DialogResult.OK Then
srcfolderString = fbd.SelectedPath
'create empty zip file
Dim fileContents() As Byte = {80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
My.Computer.FileSystem.WriteAllBytes(dstfolderString, fileContents, False)
Dim objShell As New Shell32.ShellClass
Dim objFolderSrc As Shell32.Folder
Dim objFolderDst As Shell32.Folder
Dim objFolderItems As Shell32.FolderItems
objFolderSrc = objShell.NameSpace(srcfolderString)
objFolderDst = objShell.NameSpace(dstfolderString)
objFolderItems = objFolderSrc.Items
objFolderDst.CopyHere(objFolderItems, 20)
End If
You also need to add a reference to Microsoft Shell Controls And Automation
Thanks for that
What will the end user need to unzip a folder using WinXP built in compression: EG net frame work 2.0 only?
I tried your example on a new folder i placed on the desktop and got "Access to the path 'C:\Documents and Settings\toe\Desktop\New Folder' is denied."
Any ideas?
Negative0
I will check that out what you stated n your post a few years ago if i carnt use the WinXp built in compression.
thanks