Showing posts with label Decompress using GZipStream c#. Show all posts
Showing posts with label Decompress using GZipStream c#. Show all posts

Monday 14 December 2015

Decompress using GZipStream c#

 /// <summary>
        /// Decompress the Stream
        /// </summary>
        /// <param name="data">Compress data</param>
        /// <returns></returns>
        static byte[] Decompress(byte[] data)
        {
            try
            {
                using (var compressedStream = new MemoryStream(data))
                using (var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress))
                using (var resultStream = new MemoryStream())
                {
                    zipStream.CopyTo(resultStream);
                    return resultStream.ToArray();
                }
            }
            catch
            {
                throw;
            }
        }