C# DeflateStream CopyTo(Stream)
Description
DeflateStream CopyTo(Stream)
Reads the bytes from the
current stream and writes them to another stream.
Syntax
DeflateStream.CopyTo(Stream)
has the following syntax.
public void CopyTo(
Stream destination
)
Parameters
DeflateStream.CopyTo(Stream)
has the following parameters.
destination
- The stream to which the contents of the current stream will be copied.
Returns
DeflateStream.CopyTo(Stream)
method returns
Example
The following example copies the contents of a FileStream to a MemoryStream.
using System;/* w w w . j av a2s. c o m*/
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);
}
Console.WriteLine("Destination length: {0}", destination.Length.ToString());
}
}