How to

copy stream to stream

Published: 13. December 2008 | Updated: 9. October 2011
License: Microsoft Public License (MS-PL)
Categories: Streams
Tags: C#
Was this snippet helpful for you? YESYES / NONO
Get Analyzant!

Check your entire website from code to content in minutes with Analyzant, the free analysis suite.

Free download at

Method for copy stream to stream
public static void CopyStream(Stream input, Stream output)
    int bufferSize = 4096;
    byte[] buffer = new byte[bufferSize];
    while (true)
        int read = input.Read(buffer, 0, buffer.Length);
        if (read <= 0)
        output.Write(buffer, 0, read);
Send us feedback about this snippet »

Related Snippets: