Copy Stream to Stream - CSharp File IO

CSharp examples for File IO:File Command

Description

Copy Stream to Stream

Demo Code


using System.IO;// w w w  .j  a v  a  2 s  . co m
using System;

public class Main{
        public static void Copy(Stream dst, Stream src)
        {
            long l = src.Position;
            byte[] buffer = new byte[bufferLen];
            while (true)
            {
                int n = src.Read(buffer, 0, bufferLen);
                if (n == 0)
                {
                    break;
                }
                dst.Write(buffer, 0, n);
            }
            src.Seek(l, SeekOrigin.Begin);
        }
}

Related Tutorials