Zip SharpZipLib examples for VB

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • CodeTalker

    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.

  • chad

    #2
    RE: Zip SharpZipLib examples for VB

    you can download the example codes here...
    ICSharpCode has 20 repositories available. Follow their code on GitHub.




    "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.
    >
    >

    Comment

    • chad

      #3
      RE: Zip SharpZipLib examples for VB

      not tested. but something like this......

      Imports System.IO
      Imports ICSharpCode.Sha rpZipLib.Checks ums
      Imports ICSharpCode.Sha rpZipLib.Zip
      Imports ICSharpCode.Sha rpZipLib.GZip

      Private Sub BtnZipItClick(B yVal sender As System.Object, ByVal e As
      System.EventArg s) Handles Button2.Click
      Try

      Dim objCrc32 As New Crc32()
      Dim zos As ZipOutputStream

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

      Dim strFile As String

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

      strmFile.Read(a byBuffer, 0, abyBuffer.Lengt h)
      Dim objZipEntry As ZipEntry = New ZipEntry(strFil e)

      objZipEntry.Dat eTime = DateTime.Now
      objZipEntry.Siz e = strmFile.Length
      strmFile.Close( )
      objCrc32.Reset( )
      objCrc32.Update (abyBuffer)
      objZipEntry.Crc = objCrc32.Value
      zos.PutNextEntr y(objZipEntry)
      zos.Write(abyBu ffer, 0, abyBuffer.Lengt h)


      zos.Finish()
      zos.Close()


      MessageBox.Show ("Operation complete")


      Catch ex As Exception
      MsgBox(ex.ToStr ing)
      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.
      >
      >

      Comment

      • CodeTalker

        #4
        Re: Zip SharpZipLib examples for VB

        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.Sha rpZipLib.Checks ums
        Imports ICSharpCode.Sha rpZipLib.Zip
        Imports ICSharpCode.Sha rpZipLib.GZip
        >
        Private Sub BtnZipItClick(B yVal sender As System.Object, ByVal e As
        System.EventArg s) Handles Button2.Click
        Try
        >
        Dim objCrc32 As New Crc32()
        Dim zos As ZipOutputStream
        >
        zos = New ZipOutputStream (File.Create(Te xtBox2.Text)) 'your
        zipfile
        >
        Dim strFile As String
        >
        Dim strmFile As FileStream = File.OpenRead(y ourFilename)
        Dim abyBuffer(CInt( strmFile.Length - 1)) As Byte
        >
        strmFile.Read(a byBuffer, 0, abyBuffer.Lengt h)
        Dim objZipEntry As ZipEntry = New ZipEntry(strFil e)
        >
        objZipEntry.Dat eTime = DateTime.Now
        objZipEntry.Siz e = strmFile.Length
        strmFile.Close( )
        objCrc32.Reset( )
        objCrc32.Update (abyBuffer)
        objZipEntry.Crc = objCrc32.Value
        zos.PutNextEntr y(objZipEntry)
        zos.Write(abyBu ffer, 0, abyBuffer.Lengt h)
        >
        >
        zos.Finish()
        zos.Close()
        >
        >
        MessageBox.Show ("Operation complete")
        >
        >
        Catch ex As Exception
        MsgBox(ex.ToStr ing)
        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.

        Comment

        Working...