[*] Hello Snoopy

.NET and Flash Blog
从SQL中读取的数据流并实现下载
从数据库读出的文件流下载
private void Page_Load(object sender, System.EventArgs e)
        
{
            
string id = Request.QueryString["ID"as string;
            IAccessoryRoot root 
= new AccessoryRoot(WebDefine.DBSealConn);
            AccessoryController ctrl 
= root.AccessoryController;
            Accessory a 
= ctrl.GetAccessory(id);
            
if(a != null)
            
{
        
                Response.Clear();
                
//Response.ContentType = a.ContentType;
                Response.ContentType = "application/x-www-form-urlencoded";
                
//Response.AddHeader("Content-Length", a.Size.ToString());
                Response.AddHeader("Content-Disposition""attachment; filename=" + a.Name);
                Response.BinaryWrite(a.ContentBytes);

                Response.End();
                Response.Close();
            }

            
else
            
{
                Response.Write(
"文件不存在或已被删除.");
            }

        }

posted on 2004-11-11 14:54  HelloSnoopy  阅读(606)  评论(0)    收藏  举报