Example #1
0
        public static void TransferTo(this Stream from, Stream to, int bufferSize,
            StreamBlockCopiedHandler blockCopiedHandler)
        {
            long bytes_read = 0;
            byte [] buffer = new byte[bufferSize];
            int chunk_bytes_read = 0;

            while (true) {
                bool final = !((chunk_bytes_read = from.Read (buffer, 0, buffer.Length)) > 0);
                to.Write (buffer, 0, chunk_bytes_read);
                bytes_read += chunk_bytes_read;

                if (blockCopiedHandler != null) {
                    blockCopiedHandler (bytes_read, final, buffer, chunk_bytes_read);
                }

                if (final) {
                    break;
                }
            }
        }
Example #2
0
 public static void TransferTo(this Stream from, Stream to, StreamBlockCopiedHandler blockCopiedHandler)
 {
     TransferTo (from, to, 8192, blockCopiedHandler);
 }