VB.net code to compress a file

Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 1492
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)

End Using
End Using
End Using
End Sub

Comments or Responses

Login to post response