StremReader.ReadToEnd() returning an empty string
- by axk
I have a method
private static String DecompressAndDecode(byte[] data)
{
GZipStream decompressor = new GZipStream(new MemoryStream(data), CompressionMode.Decompress);
StreamReader decompressed = new StreamReader(decompressor, Encoding.UTF8);
String result = decompressed.ReadToEnd();
return result;
}
I have some GZipped text as input and the result is supposed to be a String representation of this text. The problem is that the method returns an empty string. What is puzzling me is that when I step trough the method in debug mode and reach the return statement the result variable is an empty string but if I create a watch for the decompressed.ReadToEnd() expression it returns me the text. What I would expect at this point is the result variable to contain the text and the decompressed.ReadToEnd() expression evaluating to an empty string. (Reevaluating the decompressed.ReadToEnd() expression returns an empty string as expected).
There must be something obvious I'm missing here.