"Unknown block type. Stream might be corrupted." in VB.net vs2013

Manikandan s 1 Reputation point
2021-06-21T08:54:23.15+00:00

In the below code, am getting an error "Unknown block type. Stream might be corrupted.".
am passing BLOB value as parameter (pbyCompressStream)..

Public Function DecompressStream(ByVal pbyCompressStream As Byte()) As Byte()
Dim Value As Byte() = Nothing
Dim oUnCompressStream As MemoryStream = Nothing
Dim oCompressStream As MemoryStream = Nothing
Dim oDecompressObject As Compression.DeflateStream = Nothing
Dim oBuffer(4096) As Byte
Dim nRead As Integer

    Try
        oUnCompressStream = New MemoryStream
        oCompressStream = New MemoryStream(pbyCompressStream, 0, pbyCompressStream.Length, True, True)
        oDecompressObject = New Compression.DeflateStream(oCompressStream, Compression.CompressionMode.Decompress)
        ' Copy the compressed file into the decompression stream.

         nRead = oDecompressObject.Read(oBuffer, 0, oBuffer.Length)

        Do While nRead > 0
            oUnCompressStream.Write(oBuffer, 0, nRead)
            nRead = oDecompressObject.Read(oBuffer, 0, oBuffer.Length)
        Loop
        Value = oUnCompressStream.ToArray
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,564 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Xingyu Zhao-MSFT 5,356 Reputation points
    2021-06-23T05:51:02.807+00:00

    Hi @Manikandan s ,
    How do you compress the data? The problem may be related to your Encoding.
    Check: DeflateStream decompression issue
    Another related reference you can refer to:
    DeflateStream not decompressing data (the first time)

    Best Regards,
    Xingyu Zhao
    *
    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments