小格
没有目标的人,是在帮那些有目标的人完成目标。

<%@ WebHandler Language="C#" class="Handler" %>

using System;
using System.Web;
using System.IO;
using System.Drawing;

public class Handler : IHttpHandler {
   
    public void ProcessRequest (HttpContext context) {
        string path = System.Configuration.ConfigurationManager.AppSettings["imgpath"].ToString().Trim() + context.Request.QueryString["sheetid"]; 
        if (!string.IsNullOrEmpty(path)) 
        { 
           FileStream fs = new FileStream(@path, FileMode.Open, FileAccess.Read); 
           Bitmap myImage = new Bitmap(fs); 
            
            MemoryStream ms = new MemoryStream(); 
            myImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); 
            context.Response.ClearContent(); 
            context.Response.ContentType = "image/Jpeg"; 
            context.Response.BinaryWrite(ms.ToArray()); 
        } 
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}

posted on 2013-12-18 12:11  小格  阅读(227)  评论(0编辑  收藏  举报