Code:
string SQL = "SELECT FileName,FileSize,ContentType,FileData FROM FileTable WHERE FileID = '" + FileID + "'";
SqlConnection con = Connection.GetConnection();
SqlCommand cmd = new SqlCommand();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(SQL, con);
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
da.Fill(dt);
Byte[] bytes = System.Text.Encoding.Unicode.GetBytes(dt.Rows[0][3].ToString());
Response.Buffer = true;
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = dt.Rows[0][2].ToString();
Response.AddHeader("content-disposition", "attachment;filename=" + dt.Rows[0][0].ToString());
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
Comment