Answer the question
In order to leave comments, you need to log in
c# GzipStream decompress stream only if it is really packed
In general, the question is not obvious at first glance.
What we have: We have
an inputStream .
We know that it is possibly gzipped. And perhaps not.
What is required:
It is
required to read this stream, decompressing if necessary.
If you just wrap it in a GzipStream, it will crash with the error "The magic number in GZip header is not correct".
What's the catch:
You can't just subtract the stream into byte[], and then play with this array, as there are severe speed limits.
Does anyone have any suggestions how to do this?
Answer the question
In order to leave comments, you need to log in
Offhand: make a wrapper stream that will check magic and then pass or not pass through GZipStream.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question