/// <summary> /// Reads all bytes. /// </summary> /// <param name="source">The source.</param> /// <returns></returns> public static byte[] ReadAllBytes(this Stream source) { using (var destination = new MemoryStream()) { StreamPipe.Transfer(source, destination); return(destination.ToArray()); } }
/// <summary> /// Decompresses the specified data. /// </summary> /// <param name="data">The data.</param> /// <returns></returns> public static byte[] Decompress(byte[] data) { using (var dataStream = new MemoryStream(data)) using (var gzip = new GZipStream(dataStream, CompressionMode.Decompress, true)) using (var output = new MemoryStream()) { StreamPipe.Transfer(gzip, output); return(output.ToArray()); } }