why can't I get this code here to work? I want to call this on a byte array that was previously compressed....anyway, it just returns an empty string...
public static string FromGZipToString( this byte[] source )
{
using( MemoryStream stream = new MemoryStream( ) )
{
stream.Write( source, 0, source.Length );
using (var gzipstream = new GZipStream(stream, CompressionMode.Decompress))
using (var reader = new StreamReader(gzipstream))
{
return reader.ReadToEnd( );
}
}
}
here is the compress code by the way....
public static byte[] ToGZip( this string source )
{
using( var stream = new MemoryStream( ) )
using( var compressor = new GZipStream( stream, CompressionMode.Compress ) )
{
var bytes = System.Text.UTF8Encoding.UTF8.GetBytes( source );
compressor.Write( bytes, 0, bytes.Length );
return stream.ToArray( );
}
}