I am in need of a way to write a GZipStream to a string.
I am using:
GZipStream Decompress = new GZipStream(inFile, CompressionMode.Decompress)
I have tried several methods, but can’t figure it out.
Does anyone have any ideas?
Many thanks,
Brett
You have a decompressing
GZipStream, so you need to read data from it. The easiest way is to wrap theGZipStreamwith aStreamReaderwhich has aReadToEndmethod returning a string.Something like:
(
usingstatements ensure thatinFileis closed and any other resources are freed.)NB this does assume that
inFilecontains text encoded UTF-8 or UTF-16. Binary content or other text encoding could cause problems (you can override the encoding with a differentStreamReaderconstructor).