пятница, 28 ноября 2008 г.

Write Image to Response.OutputStream - ASP.NET

read an image from disk and write it out to the Response.Outputstream.


public void ProcessRequest(HttpContext oContext, string sFileName)
{

string sPath=oContext.Server.MapPath(".");
try
{
if (sFileName.Length <1) { return; }
System.Drawing.Image oImg = System.Drawing.Image.FromFile(sPath + sFileName,true);
oImg.Save(oContext.Response.OutputStream,ImageFormat.Jpeg);
oImg.Dispose();
}
catch (Exception e) { oContext.Response.Write(e.Message); }

}

Комментариев нет: