开发者

Convert Image to Byte[]

I have an image that sits inside some folder in my MVC3 application. In my controller, how do I convert that image into 开发者_运维技巧a Byte array.


byte[] buffer = File.ReadAllBytes("foo.png");

and because that's inside a controller you probably want to calculate the path relative to the root:

string imageFile = Path.Combine(Server.MapPath("~/App_Data"), "foo.png");
byte[] buffer = File.ReadAllBytes(imageFile);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜