By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,263 Members | 1,365 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,263 IT Pros & Developers. It's quick & easy.

Zip SharpZipLib examples for VB

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.