473,385 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Zip SharpZipLib examples for VB

I am new to VB.NET and SharpZipLib for that matter. I need the ability
to zip a single file. I have found many examples of unzipping a zip
file but not one to actually zip one. If anyone has an example of this
I would GREATLY appreciate it.

Oct 26 '06 #1
3 36938
you can download the example codes here...
http://www.icsharpcode.net/OpenSourc.../Download.aspx

"CodeTalker" wrote:
I am new to VB.NET and SharpZipLib for that matter. I need the ability
to zip a single file. I have found many examples of unzipping a zip
file but not one to actually zip one. If anyone has an example of this
I would GREATLY appreciate it.

Oct 26 '06 #2
not tested. but something like this......

Imports System.IO
Imports ICSharpCode.SharpZipLib.Checksums
Imports ICSharpCode.SharpZipLib.Zip
Imports ICSharpCode.SharpZipLib.GZip

Private Sub BtnZipItClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Try

Dim objCrc32 As New Crc32()
Dim zos As ZipOutputStream

zos = New ZipOutputStream(File.Create(TextBox2.Text)) 'your
zipfile

Dim strFile As String

Dim strmFile As FileStream = File.OpenRead(yourFilename)
Dim abyBuffer(CInt(strmFile.Length - 1)) As Byte

strmFile.Read(abyBuffer, 0, abyBuffer.Length)
Dim objZipEntry As ZipEntry = New ZipEntry(strFile)

objZipEntry.DateTime = DateTime.Now
objZipEntry.Size = strmFile.Length
strmFile.Close()
objCrc32.Reset()
objCrc32.Update(abyBuffer)
objZipEntry.Crc = objCrc32.Value
zos.PutNextEntry(objZipEntry)
zos.Write(abyBuffer, 0, abyBuffer.Length)
zos.Finish()
zos.Close()
MessageBox.Show("Operation complete")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub




"CodeTalker" wrote:
I am new to VB.NET and SharpZipLib for that matter. I need the ability
to zip a single file. I have found many examples of unzipping a zip
file but not one to actually zip one. If anyone has an example of this
I would GREATLY appreciate it.

Oct 26 '06 #3
Thanks Chad. I really appreciate the help. I think that will work great
for what I need.

chad wrote:
not tested. but something like this......

Imports System.IO
Imports ICSharpCode.SharpZipLib.Checksums
Imports ICSharpCode.SharpZipLib.Zip
Imports ICSharpCode.SharpZipLib.GZip

Private Sub BtnZipItClick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Try

Dim objCrc32 As New Crc32()
Dim zos As ZipOutputStream

zos = New ZipOutputStream(File.Create(TextBox2.Text)) 'your
zipfile

Dim strFile As String

Dim strmFile As FileStream = File.OpenRead(yourFilename)
Dim abyBuffer(CInt(strmFile.Length - 1)) As Byte

strmFile.Read(abyBuffer, 0, abyBuffer.Length)
Dim objZipEntry As ZipEntry = New ZipEntry(strFile)

objZipEntry.DateTime = DateTime.Now
objZipEntry.Size = strmFile.Length
strmFile.Close()
objCrc32.Reset()
objCrc32.Update(abyBuffer)
objZipEntry.Crc = objCrc32.Value
zos.PutNextEntry(objZipEntry)
zos.Write(abyBuffer, 0, abyBuffer.Length)
zos.Finish()
zos.Close()
MessageBox.Show("Operation complete")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub




"CodeTalker" wrote:
I am new to VB.NET and SharpZipLib for that matter. I need the ability
to zip a single file. I have found many examples of unzipping a zip
file but not one to actually zip one. If anyone has an example of this
I would GREATLY appreciate it.
Oct 26 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Christer | last post by:
Hi all, I've been trying to use the SharpZipLib as it sounds promising and a lot of people refer to it in discussions on compression. However, I am getting some bad output, when I try to unzip a...
1
by: BeanDog | last post by:
I know this is a horse that's been beated good and dead, but I *still* can't find a good solution to this. I suppose I should post this on SharpZipLib's forums, but I signed up and they never sent...
1
by: Calvin Slater | last post by:
I am always getting the following error when debuging ASP.NET application: Access is denied: 'ICSharpCode.SharpZipLib'. At this point I have to reboot IIS to get the web site going again. It...
1
by: Flix | last post by:
The following piece of code should turn the folder IN and its subfolders into a single tar file located in the folder OUT: using ICSharpCode.SharpZipLib; using ICSharpCode.SharpZipLib.Tar; ...
3
by: Chris | last post by:
Does anyone know how to make a zip file using SharpZipLib that can be opened by Windows Explorer? I get an empty file when I try to open it with explorer using their example. Chris
0
by: arachno | last post by:
Hello, Is nayone have any examples how to decompress bytearray into string/bytearray via gZip (ICSharpCode.SharpZipLib.GZip/ or any other, if any) ? Thnx, Ev.
1
by: Brian Henry | last post by:
I keep getting this error when decompressing any zip files.. ICSharpCode.SharpZipLib.ZipException: Wrong Local header signature: 0xB023867F at...
4
by: Sam | last post by:
Hi all, Does someone knows if I can use this librairy (ICSharpCode.SharpZipLib.Zip) for free ? It is used to zip files (as you can probably guess). Thank you very much. Samuel
1
by: Aji Mathews via .NET 247 | last post by:
Hi I am using SharpZipLib. Could someone help with some sample code to unzip a file to a specified location. Thanks -------------------------------- From: Aji Mathews ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.