Created
August 7, 2014 09:29
-
-
Save kjeske/815984ad532d5e0e591a to your computer and use it in GitHub Desktop.
Stream.ToByteArray
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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