Exemplo n.º 1
0
        public static void EndCopy(IAsyncResult ar)
        {
            StreamCopyState result = (StreamCopyState)ar;

            if (result.Error != null)
            {
                throw result.Error;
            }
        }
Exemplo n.º 2
0
        public static IAsyncResult BeginCopy(Stream from, Stream to, AsyncCallback callback, object state)
        {
            byte[] buffer = new byte[32768];

            StreamCopyState asyncState = new StreamCopyState(from, to, buffer, callback, state);

            from.BeginRead(buffer, 0, buffer.Length, asyncState.DataRead, null);

            return(asyncState);
        }