public Read ( System buffer, System offset, System count ) : |
||
buffer | System | |
offset | System | |
count | System | |
return |
/// <summary> /// Read data from the stream. /// </summary> /// /// <remarks> /// /// <para> /// If you wish to use the ZlibStream to compress data while reading, you can create a /// ZlibStream with CompressionMode.Compress, providing an uncompressed data stream. Then /// call Read() on that ZlibStream, and the data read will be compressed. If you wish to /// use the ZlibStream to decompress data while reading, you can create a ZlibStream with /// CompressionMode.Decompress, providing a readable compressed data stream. Then call /// Read() on that ZlibStream, and the data will be decompressed as it is read. /// </para> /// /// <para> /// A ZlibStream can be used for Read() or Write(), but not both. /// </para> /// </remarks> /// <param name="buffer">The buffer into which the read data should be placed.</param> /// <param name="offset">the offset within that data array to put the first byte read.</param> /// <param name="count">the number of bytes to read.</param> public override int Read(byte[] buffer, int offset, int count) { if (_disposed) { throw new ObjectDisposedException("ZlibStream"); } return(_baseStream.Read(buffer, offset, count)); }
/// <summary> /// Read and decompress data from the source stream. /// </summary> /// <remarks> /// With a GZipStream, decompression is done through reading. /// </remarks> /// <example> /// <code> /// byte[] working = new byte[WORKING_BUFFER_SIZE]; /// using (System.IO.Stream input = System.IO.File.OpenRead(_CompressedFile)) /// { /// using (Stream decompressor= new Ionic.Zlib.GZipStream(input, CompressionMode.Decompress, true)) /// { /// using (var output = System.IO.File.Create(_DecompressedFile)) /// { /// int n; /// while ((n= decompressor.Read(working, 0, working.Length)) !=0) /// { /// output.Write(working, 0, n); /// } /// } /// } /// } /// </code> /// </example> /// <param name="buffer">The buffer into which the decompressed data should be placed.</param> /// <param name="offset">the offset within that data array to put the first byte read.</param> /// <param name="count">the number of bytes to read.</param> /// <returns>the number of bytes actually read</returns> 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); }