更新经典的asp方法,将.exe文件流式传输给用户
本文关键字:文件 传输 给用户 exe 经典 asp 方法 更新 | 更新日期: 2023-09-27 18:28:15
我正在将一个经典的asp页面转换为.net,并遇到了以下代码:
Sub SendBinaryFile(b_FileName)
tool = Server.MapPath("bin/" & b_FileName)
Response.AddHeader "Content-Disposition", "attachment;filename=" & b_FileName
Response.ContentType = "application/octet-stream"
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Open
BinaryStream.Type = 1
BinaryStream.LoadFromFile tool
Response.BinaryWrite BinaryStream.Read
BinaryStream.Close
Set BinaryWrite = Nothing
End Sub
我以前在.net中没有这样做过,所以我想知道向用户流式传输.exe文件的正确方法是什么?谢谢
在.Net中要简单得多…
tool = Server.MapPath("bin/" & b_FileName)
Response.AddHeader("Content-Disposition", "attachment;filename=" & b_FileName)
Response.ContentType = "application/octet-stream"
Response.BinaryWrite(File.ReadAllBytes(tool))