TizzyT

DEFLATE Compress/Decompress -TizzyT

Jan 17th, 2016
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.93 KB | None | 0 0
  1.     Public Function Compress(ByVal Data As Byte()) As Byte()
  2.         Using DataStream As New MemoryStream(Data)
  3.             Using CompressedStream As New MemoryStream
  4.                 Using CompressionStream As New DeflateStream(CompressedStream, CompressionMode.Compress)
  5.                     DataStream.CopyTo(CompressionStream)
  6.                 End Using
  7.                 Return CompressedStream.ToArray
  8.             End Using
  9.         End Using
  10.     End Function
  11.  
  12.     Public Function Decompress(ByVal Data As Byte()) As Byte()
  13.         Using DataStream As New MemoryStream(Data)
  14.             Using DecompressedStream As New MemoryStream()
  15.                 Using DecompressionStream As New DeflateStream(DataStream, CompressionMode.Decompress)
  16.                     DecompressionStream.CopyTo(DecompressedStream)
  17.                 End Using
  18.                 Return DecompressedStream.ToArray
  19.             End Using
  20.         End Using
  21.     End Function
Advertisement
Add Comment
Please, Sign In to add comment