473,396 Members | 1,784 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,396 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 36946
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.