PdfRpt.Core.Helper.StreamHelper.StreamToBytes C# (CSharp) Method

StreamToBytes() public static method

Converts StreamToBytes
public static StreamToBytes ( this input ) : byte[]
input this stream
return byte[]
        public static byte[] StreamToBytes(this Stream input)
        {
            var capacity = input.CanSeek ? (int)input.Length : 0;
            using (var output = new MemoryStream(capacity))
            {
                int readLength;
                var buffer = new byte[4096];

                do
                {
                    readLength = input.Read(buffer, 0, buffer.Length);
                    output.Write(buffer, 0, readLength);
                }
                while (readLength != 0);

                return output.ToArray();
            }
        }