How to

convert stream to bytes array

Published: 2. February 2014 | Updated: 2. February 2014
License: Microsoft Public License (MS-PL)
Categories: Converting, Streams
Tags: C# Conversion
Was this snippet helpful for you? YESYES / NONO
Get Analyzant!

Check your entire website from code to content in minutes with Analyzant, the free analysis suite.

Free download at

Import namespaces

using System.IO;


public static byte[] StreamToBytes(Stream stream)
    using (var memoryStream = new MemoryStream())
        return memoryStream.ToArray();
Send us feedback about this snippet »

Related Snippets: