Return all bytes from current stream position to the end of the stream - CSharp System.IO

CSharp examples for System.IO:Stream

Description

Return all bytes from current stream position to the end of the stream

Demo Code


using System.Text;
using System.IO;//from  ww  w. j  a  v a 2 s . co  m
using System.Collections.Generic;
using System;

public class Main{
        /// <summary>
        /// Return all bytes from current stream position to the end of the stream
        /// </summary>
        public static byte[] ReadAllBytes(Stream stream)
        {
            byte[] buffer = new byte[stream.Length - stream.Position];
            stream.Read(buffer, 0, buffer.Length);
            return buffer;
        }
}

Related Tutorials