附件下载

//FWay.Data.DataSql ds = new FWay.Data.DataSql(FWay.Data.DataFactory.GetConfigFile(FWay.Data.SysMode.Web), BaseClass.Define.dbKeyFiles);
SqlConnection cn = new SqlConnection();
SqlDataReader dr = null;
if (ds.OpenConnection(ref cn))
{
string str_Sql = "";
MemoryStream ms = new MemoryStream();
SqlCommand cm = new SqlCommand(string.Format(str_Sql, hidden_Download.Value), cn);
dr = cm.ExecuteReader();
if (dr.Read())
{
byte[] File = (byte[])dr[1];
string strName = dr[0].ToString() + dr[2].ToString();
strName = HttpUtility.UrlEncode(strName, System.Text.Encoding.GetEncoding("UTF-8"));
Response.AddHeader("content-disposition", "attachment;filename=" + strName);
Response.BinaryWrite(File);
Response.Flush();
Response.End();
}
dr.Close();
cm.Clone();
}

posted @ 2016-09-20 16:50  咧嘴玩手机的猫  阅读(117)  评论(0编辑  收藏  举报