Me.AccessDataSource1.SelectCommand =
"select * from FileStorage where uid=" & Request.QueryString("FileID")
Dim dv As Data.DataView = Me.AccessDataSource1.Select(New DataSourceSelectArguments)
'准备下载文件
Response.ClearHeaders()
Response.Clear()
Response.Expires = 0
Response.Buffer = True
Dim fileName As String = dv.Item(0).Item("FileName")
'通过 Header 设定文件名
Response.AddHeader("content-disposition", "attachment;
filename=" & Chr(34) & System.Web.HttpUtility.UrlEncode(IO.Path.GetFileName(fileName),
System.Text.Encoding.UTF8) & Chr(34))
Response.ContentType = "Application/octet-stream"
'传出要让使用者下载的内容
Response.BinaryWrite(dv.Item(0).Item("FileBody"))
'释放资源
Response.End()