Decompress the underlying stream. : GZipStream « File Directory « VB.Net






Decompress the underlying stream.

 

Imports System.IO
Imports System.IO.Compression
Module Module1
    Sub Main()
        Dim dirpath As String = "c:\"
        Dim di As DirectoryInfo = New DirectoryInfo(dirpath)
        For Each fi As FileInfo In di.GetFiles("*.gz")
            Decompress(fi)
        Next
    End Sub
    Private Sub Decompress(ByVal fi As FileInfo)
        Using inFile As FileStream = fi.OpenRead()
            Dim curFile As String = fi.FullName
            Dim origName = curFile.Remove(curFile.Length - fi.Extension.Length)
            Using outFile As FileStream = File.Create(origName)
                Using Decompress As GZipStream = New GZipStream(inFile, _
                  CompressionMode.Decompress)
                    Decompress.CopyTo(outFile)
                    Console.WriteLine("Decompressed: {0}", fi.Name)
                End Using
            End Using
        End Using
    End Sub
End Module

   
  








Related examples in the same category

1.Compress
2.Compress the underlying stream.