VB.net code to compress a file

Rajnilari2015
Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 232
The below code will do so

Public Shared Sub CompressFile(filePath As String)
Dim info As New FileInfo(filePath)

Using originalFileStream As FileStream = info.OpenRead()

Using compressedFileStream As FileStream = File.Create(filePath & Convert.ToString(".gz"))
Using compressionStream As New GZipStream(compressedFileStream, CompressionMode.Compress)

originalFileStream.CopyTo(compressionStream)
End Using
End Using
End Using
End Sub

Comments or Responses

Login to post response