|
Always close DeflateStream before reading results (Development | .NET)
Is the code below correct? Will inputString and outputString be equal?
As it turns out, they won't. The reason for it being that compressionStream.Close() was not called before reading from stream started. Calling compressionStream.Flush() is not enough in this case. I haven't managed to find this documented anywhere but the example in the DeflateStream documentation does it correctly. You can find the fixed code below. Notice the additional last parameter in the first call to the DeflateStream constructor. Without it stream will also be closed when compressionStream gets closed.
Thanks once again to my coworker for suggesting this when I was already running out of ideas.
11/24/2007 4:44:37 PM (Central Europe Standard Time, UTC+01:00)
|