System.IO.Compression.GZipStream.ReadAsync C# (CSharp) Method

ReadAsync() public method

public ReadAsync ( byte array, int offset, int count, System cancellationToken ) : System.Threading.Tasks.Task
array byte
offset int
count int
cancellationToken System
return System.Threading.Tasks.Task
        public override System.Threading.Tasks.Task<int> ReadAsync(byte[] array, int offset, int count, System.Threading.CancellationToken cancellationToken) { throw null; }
        public override long Seek(long offset, System.IO.SeekOrigin origin) { throw null; }

Same methods

GZipStream::ReadAsync ( byte array, int offset, int count, CancellationToken cancellationToken ) : Task

Usage Example

Exemplo n.º 1
1
        /// <summary>  
        /// decompress gzip data
        /// </summary>  
        /// <param name="data">compressed data</param>  
        /// <returns></returns>  
        public async static Task<byte[]> Decompress(byte[] data)
        {
            MemoryStream ms = null;
            GZipStream compressedzipStream = null;
            MemoryStream outBuffer = new MemoryStream();

            try
            {
                ms = new MemoryStream(data);
                compressedzipStream = new GZipStream(ms, CompressionMode.Decompress);

                byte[] block = new byte[1024 * 16];
                while (true)
                {
                    int bytesRead = await compressedzipStream.ReadAsync(block, 0, block.Length);
                    if (bytesRead <= 0)
                    {
                        break;
                    }
                    else
                    {
                        outBuffer.Write(block, 0, bytesRead);
                    }
                }
            }
            finally
            {
                if (null != compressedzipStream) compressedzipStream.Close();
                if (null != ms) ms.Close();
            }

            return outBuffer.ToArray();
        }
All Usage Examples Of System.IO.Compression.GZipStream::ReadAsync