The ZipInputStream objects read method is returning the following message when I try to inflate from a byte array.
Unable to read from this stream
My code is below:
Public Shared Function Uncompress_Memory_Data(ByVal bData As Byte()) As Byte()
Dim strmZipInputStream As ZipInputStream = Nothing
Dim strmData As MemoryStream
Dim bResult As Byte() = Nothing
Dim bTemp As Byte() = Nothing
Dim iReadSize As Integer = 2048
Dim iRead As Integer = 0
Dim iOffset As Integer = 0
Try
' Simple sanity checks
If bData.Length = 0 Then
m_Error_Message = "DataCompression.Uncompress_Memory_Data: No data to uncompress."
Else
strmData = New MemoryStream(bData)
strmData.Position = 0
strmZipInputStream = New ZipInputStream(strmData)
ReDim bTemp(iReadSize)
Do While True
iRead = strmZipInputStream.Read(bTemp, 0, bTemp.Length)
If iRead = 0 Then
Exit Do
End If
Array.Copy(bTemp, 0, bResult, iOffset, iRead)
iOffset += iRead
Loop
End If
strmZipInputStream.Close()
Catch ex As Exception
m_Error_Message = "DataCompression.Uncompress_Memory_Data " & ex.Message
bResult = Nothing
Finally
strmData = Nothing
strmZipInputStream = Nothing
bTemp = Nothing
End Try
Return bResult
End Function
Any help would be appreciated.
Thank you