public Write ( System buffer, int offset, int count ) : void | ||
buffer | System | |
offset | int | |
count | int | |
return | void |
/// <summary> /// Write data to the stream. /// </summary> /// /// <remarks> /// /// <para> /// If you wish to use the <c>ZlibStream</c> to compress data while writing, /// you can create a <c>ZlibStream</c> with <c>CompressionMode.Compress</c>, /// and a writable output stream. Then call <c>Write()</c> on that /// <c>ZlibStream</c>, providing uncompressed data as input. The data sent to /// the output stream will be the compressed form of the data written. If you /// wish to use the <c>ZlibStream</c> to decompress data while writing, you /// can create a <c>ZlibStream</c> with <c>CompressionMode.Decompress</c>, and a /// writable output stream. Then call <c>Write()</c> on that stream, /// providing previously compressed data. The data sent to the output stream /// will be the decompressed form of the data written. /// </para> /// /// <para> /// A <c>ZlibStream</c> can be used for <c>Read()</c> or <c>Write()</c>, but not both. /// </para> /// </remarks> /// <param name="buffer">The buffer holding data to write to the stream.</param> /// <param name="offset">the offset within that data array to find the first byte to write.</param> /// <param name="count">the number of bytes to write.</param> public override void Write(byte[] buffer, int offset, int count) { if (_disposed) { throw new ObjectDisposedException("ZlibStream"); } _baseStream.Write(buffer, offset, count); }
/// <summary> /// Write data to the stream. /// </summary> /// /// <remarks> /// <para> /// If you wish to use the <c>GZipStream</c> to compress data while writing, /// you can create a <c>GZipStream</c> with <c>CompressionMode.Compress</c>, and a /// writable output stream. Then call <c>Write()</c> on that <c>GZipStream</c>, /// providing uncompressed data as input. The data sent to the output stream /// will be the compressed form of the data written. /// </para> /// /// <para> /// A <c>GZipStream</c> can be used for <c>Read()</c> or <c>Write()</c>, but not /// both. Writing implies compression. Reading implies decompression. /// </para> /// /// </remarks> /// <param name="buffer">The buffer holding data to write to the stream.</param> /// <param name="offset">the offset within that data array to find the first byte to write.</param> /// <param name="count">the number of bytes to write.</param> public override void Write(byte[] buffer, int offset, int count) { if (_disposed) { throw new ObjectDisposedException("GZipStream"); } if (_baseStream._streamMode == ZlibBaseStream.StreamMode.Undefined) { //Console.WriteLine("GZipStream: First write"); if (_baseStream._wantCompress) { // first write in compression, therefore, emit the GZIP header _headerByteCount = EmitHeader(); } else { throw new InvalidOperationException(); } } _baseStream.Write(buffer, offset, count); }