我正在将一个经典的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文件流式传输给用户的正确方法是什么?谢谢。
发布于 2012-03-22 00:52:34
在.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))https://stackoverflow.com/questions/9780117
复制相似问题