CSharp examples for System.IO:MemoryStream
Read MemoryStream To End
using System.Text; using System.Security.Principal; using System.IO;/* www.ja v a 2s . c o m*/ using System; public class Main{ public static byte[] ReadToEnd(this MemoryStream stream) { long remainingBytes = stream.Length - stream.Position; if(remainingBytes > int.MaxValue) { throw new ArgumentOutOfRangeException("stream"); } byte[] buffer = new byte[remainingBytes]; stream.Read(buffer, 0, (int)remainingBytes); return buffer; } }