Introduction
This project will display simple how to read/write image.
Step 1: Change your imagePath for get picture and copy code to page_load event
C#
string imagePath = Request.PhysicalApplicationPath + @"\images\5.jpg";
FileInfo fi = new FileInfo(imagePath);
int size = (int)fi.Length;
byte[] imgBytes = new byte[size];
FileStream stream = new FileStream(imagePath, FileMode.Open);
BinaryReader reader = new BinaryReader(stream);
imgBytes = reader.ReadBytes(size);
reader.Close();
Response.Clear();
Response.ClearContent();
Response.Buffer = true;
Response.ContentType = "image/jpg";
Response.BinaryWrite(imgBytes);
pls enjoy zomdev.
No comments:
Post a Comment