Пример #1
0
        public static long CopyStream(Stream dest, Stream src, CopyProgressCallback cb, long maxlen, int bufsize)
        {
            long bytescopied = 0;

            byte[] buffer = new byte[bufsize];
            int    read;

            while ((read = src.Read(buffer, 0, maxlen == -1 ? buffer.Length: (int)Math.Min(buffer.Length, maxlen - bytescopied))) > 0)
            {
                dest.Write(buffer, 0, read);
                bytescopied += read;
                if (cb != null)
                {
                    cb(bytescopied);
                }
            }
            return(bytescopied);
        }
Пример #2
0
 public static long CopyStream(Stream dest, Stream src, CopyProgressCallback cb)
 {
     return(CopyStream(dest, src, cb, -1, 32768));
 }