GitSharp.Zlib.Decompress C# (CSharp) Method

Decompress() public method

public Decompress ( Stream input ) : byte[]
input System.IO.Stream
return byte[]
        public byte[] Decompress(Stream input)
        {
            using (var output = new MemoryStream())
            using (var zipStream = new zlib.ZOutputStream(output))
            {
                using (input)
                {
                    var buffer = new byte[2000];
                    int len;

                    while ((len = input.Read(buffer, 0, 2000)) > 0)
                    {
                        zipStream.Write(buffer, 0, len);
                    }
                }

                // reset output stream to start so we can read it to a string
                output.Position = 0;

                byte[] content = new byte[output.Length];

                output.Read(content, 0, (int)output.Length);

                return content;
            }
        }

Same methods

Zlib::Decompress ( string path ) : byte[]

Usage Example

        public void CanDecompressFile()
        {
            var compression = new Zlib();
            byte[] value = compression.Decompress(@"Resources\commit");

            // should do better than this!
            Assert.That(value, Is.Not.Null);
        }
All Usage Examples Of GitSharp.Zlib::Decompress