Thursday, August 7, 2008

Write Image in Browser C#

using System.IO;
using System.Text;
using System.Xml;

protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "image/jpeg";
Response.Clear();
Response.BufferOutput = true;
//Read the Image in Byte Array
byte[] data= File.ReadAllBytes("Path of the Image");
//Write the Image in Browser
using (MemoryStream stream = new MemoryStream(data))
{
stream.WriteTo(Response.OutputStream);
}
}

No comments: