Skip to content

Instantly share code, notes, and snippets.

@kjeske
Created August 7, 2014 09:29
Show Gist options
  • Select an option

  • Save kjeske/815984ad532d5e0e591a to your computer and use it in GitHub Desktop.

Select an option

Save kjeske/815984ad532d5e0e591a to your computer and use it in GitHub Desktop.
Stream.ToByteArray
namespace System.IO
{
public static class StreamExtensions
{
public static byte[] ToByteArray(this Stream inputStream)
{
using (var memoryStream = new MemoryStream())
{
inputStream.Position = 0;
inputStream.CopyTo(memoryStream);
return memoryStream.ToArray();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment