What could be wrong with those set of methods?
byte[] bytes;
using (var memory_stream = new MemoryStream())
using (var gzip_stream = new GZipStream(memory_stream, CompressionMode.Compress))
{
var buffer = Encoding.Default.GetBytes("Hello nurse!");
gzip_stream.Write(buffer, 0, buffer.Length);
bytes = memory_stream.ToArray();
}
int total_read = 0;
using (var input_stream = new MemoryStream(bytes))
using (var gzip_stream = new GZipStream(input_stream, CompressionMode.Decompress, true))
{
int read;
var buffer = new byte[4096];
while ((read = gzip_stream.Read(buffer, 0, buffer.Length)) != 0) {
total_read += read;
}
}
Debug.WriteLine(bytes);
Debug.WriteLine(total_read);
The gzipStr is a valid Gzipped Stream (I could compress it successfully with GzipStream() Compress).
Why is total_read always 0??? is gzip stream decompressing my stream? am I doing something wrong?
What am I doing wrong here???!!!