Decompress gz file

D

DavidC

We have a file downloaded from another company in the format filename.csv.gz
that apparently was compressed with GZipStream. I would like to create a
class that decompresses it (which it does with WinZip) from an asp.net page.
I found the code below in msdn that is suppose to work. However, the line
that reads

Decompress.CopyTo(outFile)

gives an error that CopyTo is not a method in GZipStream. Can anyone help me
resolve this? It seems like a clean process if I can get it to work. Thanks.

Private Sub Decompress(ByVal fi As FileInfo)
' Get the stream of the source file.
Using inFile As FileStream = fi.OpenRead()
' Get orignial file extension, for example "doc" from
report.doc.gz.
Dim curFile As String = fi.FullName
Dim origName = curFile.Remove(curFile.Length -
fi.Extension.Length)

' Create the decompressed file.
Using outFile As FileStream = File.Create(origName)
Using Decompress As GZipStream = New GZipStream(inFile, _
CompressionMode.Decompress)

' Copy the decompression stream
' into the output file.
Decompress.CopyTo(outFile)

Console.WriteLine("Decompressed: {0}", fi.Name)

End Using
End Using
End Using
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top