Skip to content
This repository
Dru Sellers October 27, 2011
file 32 lines (26 sloc) 0.641 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
using System.IO;

namespace FubuCore
{
    public static class StreamExtensions
    {
        public static string ReadAllText(this Stream stream)
        {
            var reader = new StreamReader(stream);
            return reader.ReadToEnd();
        }


public static byte[] ReadAllBytes(this Stream stream)
{
using (var content = new MemoryStream())
{
var buffer = new byte[4096];

int read = stream.Read(buffer, 0, 4096);
while (read > 0)
{
content.Write(buffer, 0, read);

read = stream.Read(buffer, 0, 4096);
}

return content.ToArray();
}
}
    }
}
Something went wrong with that request. Please try again.