extractaction and compression of files
-
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)
-
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)
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 SubHere 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