Is MemoryStream compressed?

  • Thread starter Thread starter bamelyan
  • Start date Start date
B

bamelyan

Is there a way to determine wether a MemoryStream is compressed, i.e. needs
to be decompressed with GZipStream?
 
bamelyan said:
Is there a way to determine wether a MemoryStream is compressed, i.e. needs
to be decompressed with GZipStream?

Not really.

Bytes are just bytes.

If the first 3 bytes are 0x1f 0x8b 0x08 then there is a decent chance
it is gzipped.

Arne
 
thanks for quick response. what's the expected behavior of GZipStream if i
try to decompress a stream that is not compressed?
 
bamelyan said:
thanks for quick response. what's the expected behavior of GZipStream if i
try to decompress a stream that is not compressed?

I think one of two will happen:
* if the data just happens to be a valid GZIP format then you
will get absolute garbage
* else (and that is by far the most likely) then you will
get a InvalidDataException

Arne
 
Back
Top