Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. extractaction and compression of files

extractaction and compression of files

Scheduled Pinned Locked Moved Visual Basic
csharptoolsquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sunil goyalG
    wrote on last edited by
    #1

    hi all, how can i perform extractaction and compression of files using vb.net (without WINZIP or WINRAR mean using windows Utility or something else)

    M 1 Reply Last reply
    0
    • S sunil goyalG

      hi all, how can i perform extractaction and compression of files using vb.net (without WINZIP or WINRAR mean using windows Utility or something else)

      M Offline
      M Offline
      Manas Bhardwaj
      wrote on last edited by
      #2

      Private Sub Compress(ByVal Filename As String)
      Dim targetfile As String = IO.Path.ChangeExtension(Filename, “zdx”)
      Using sr As New IO.FileStream(Filename, IO.FileMode.Open)
      Using sw As New IO.FileStream(targetfile, IO.FileMode.OpenOrCreate)
      Using gZip As New IO.Compression.GZipStream(sw, IO.Compression.CompressionMode.Compress, False)
      Dim buffer(sr.Length) As Byte
      sr.Read(buffer, 0, buffer.Length)
      gZip.Write(buffer, 0, buffer.Length)
      gZip.Flush()
      gZip.Close()
      End Using
      sw.Close()
      End Using
      sr.Flush()
      sr.Close()
      End Using
      End Sub

      Here is the code to uncompress,

      Private Sub UnCompress(ByVal filename As String)
      Dim targetfile As String = IO.Path.ChangeExtension(filename, “doc”)
      Using sw As New IO.FileStream(targetfile, IO.FileMode.OpenOrCreate)
      Using sr As New IO.FileStream(filename, IO.FileMode.Open)
      Using gZip As New IO.Compression.GZipStream(sr, IO.Compression.CompressionMode.Decompress)
      Dim buffer(sr.Length) As Byte
      gZip.Read(buffer, 0, buffer.Length)
      sw.Write(buffer, 0, buffer.Length)
      End Using
      End Using
      End Using
      End Sub

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups