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);
精彩评论