C# DeflateStream CopyTo(Stream, Int32)

Description

DeflateStream CopyTo(Stream, Int32) Reads the bytes from the current stream and writes them to another stream, using a specified buffer size.

Syntax

DeflateStream.CopyTo(Stream, Int32) has the following syntax.


public void CopyTo(
  Stream destination,
  int bufferSize
)

Parameters

DeflateStream.CopyTo(Stream, Int32) has the following parameters.

  • destination - The stream to which the contents of the current stream will be copied.
  • bufferSize - The size of the buffer. This value must be greater than zero. The default size is 4096.

Returns

DeflateStream.CopyTo(Stream, Int32) method returns

Example


using System;//from   w  ww . java2 s .  com
using System.IO;
using System.IO.Compression;

public class Program
{
    public static void Main()
    {
        MemoryStream destination = new MemoryStream();
        
        using (FileStream source = File.Open(@"c:\temp\data.dat",FileMode.Open)){
        
            Console.WriteLine("Source length: {0}", source.Length.ToString());
            // Copy source to destination.
            source.CopyTo(destination,1024);
        }
        
        Console.WriteLine("Destination length: {0}", destination.Length.ToString());
    
    }
}




















Home »
  C# Tutorial »
    System.IO.Compression »




DeflateStream
GZipStream
ZipArchive
ZipArchiveEntry
ZipFile
ZipFileExtensions