public Read ( byte buffer, int offset, int count ) : int | ||
buffer | byte | The buffer into which the decompressed data should be placed. |
offset | int | the offset within that data array to put the first byte read. |
count | int | the number of bytes to read. |
Результат | int |
public override int Read(byte[] buffer, int offset, int count)
{
if (_disposed) throw new ObjectDisposedException("GZipStream");
int n = _baseStream.Read(buffer, offset, count);
// Console.WriteLine("GZipStream::Read(buffer, off({0}), c({1}) = {2}", offset, count, n);
// Console.WriteLine( Util.FormatByteArray(buffer, offset, n) );
if (!_firstReadDone)
{
_firstReadDone = true;
FileName = _baseStream._GzipFileName;
Comment = _baseStream._GzipComment;
}
return n;
}
public static byte[] Decompress(byte[] data) { try { MemoryStream ms = new MemoryStream(data); GZipStream zip = new GZipStream(ms, CompressionMode.Decompress, true); MemoryStream msreader = new MemoryStream(); byte[] buffer = new byte[0x1000]; while (true) { int reader = zip.Read(buffer, 0, buffer.Length); if (reader <= 0) { break; } msreader.Write(buffer, 0, reader); } zip.Close(); ms.Close(); msreader.Position = 0; buffer = msreader.ToArray(); msreader.Close(); return(buffer); } catch (IOException e) { throw new IOException(e.Message); } }