Hi,
I red all documentation and all forum's threads and didn't find a complete workable example that compress/decompress a stream . Every founded examples did not work well. Is it possible to have a complete example closer to a cut and paste?
Regards,
I put my code here. It compresses but the decompression is not functionnal:
I red all documentation and all forum's threads and didn't find a complete workable example that compress/decompress a stream . Every founded examples did not work well. Is it possible to have a complete example closer to a cut and paste?
Regards,
I put my code here. It compresses but the decompression is not functionnal:
Public
Class
Class1
Dim
msCompress
As
Stream
Public
Function
Compression(arg
As
String
)
As
String
Dim
encoding
As
New
System.Text.UTF8Encoding()
Dim
B()
As
Byte
= encoding.GetBytes(arg)
msCompress =
New
MemoryStream()
Dim
method
As
ZipCompression =
DirectCast
([
Enum
].Parse(
GetType
(ZipCompression), ZipCompression.Deflate64,
False
), ZipCompression)
Dim
zipOut
As
New
ZipOutputStream(msCompress, method)
Dim
sWriter
As
New
StreamWriter(zipOut)
sWriter.Write(B)
sWriter.Flush()
Return
(
"Compress: "
& zipOut.CompressedSize.ToString &
", Uncompress:"
& zipOut.UncompressedSize.ToString)
End
Function
Public
Function
Decompression(arg
As
String
)
As
String
Dim
encoding
As
New
System.Text.UTF8Encoding()
msCompress.Position = 0
Dim
inputStream
As
New
ZipInputStream(msCompress,
False
)
Dim
s
As
String
Dim
Reader
As
New
StreamReader(inputStream.BaseStream, encoding)
s = Reader.ReadToEnd()
Return
s
End
Function
End
Class