Created
January 14, 2012 21:45
-
-
Save terjetyl/1613007 to your computer and use it in GitHub Desktop.
Extension method for creating a byte array from a HttpPostedFileBase
This file contains 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
public static class HttpPostedFileBaseExtensions | |
{ | |
public static Byte[] ToByteArray(this HttpPostedFileBase value) | |
{ | |
if (value == null) | |
return null; | |
var array = new Byte[value.ContentLength]; | |
value.InputStream.Position = 0; | |
value.InputStream.Read(array, 0, value.ContentLength); | |
return array; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment