更新传统的ASP方法,.exe文件,流媒体用户

问题描述:

我是一个传统的ASP页面转换为.net和跨越这段代码传来:更新传统的ASP方法,.exe文件,流媒体用户

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文件流向用户的正确方法?谢谢。

+1

可能重复http://*.com/questions/736301/asp-net-how-to-stream-file-to-user http://*.com/questions/5596747/download-stream-file-from-url-asp-net – Lloyd 2012-03-20 01:30:48

+0

不是,另一个是关于如何形成网址来获取文件,然后流式传输,我的问题是'什么是标准或最佳实践! – flavour404 2012-03-20 01:40:08

+1

没有“最好”的方法。你张贴的方式是可以接受的。 – 2012-03-20 22:24:15

这是在.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)) 
+0

理查德,谢谢,我需要清理之后,冲洗什么?谢谢,罗恩。 – flavour404 2012-03-21 19:31:06

+0

你还没有创建任何对象,所以没有什么要整理:) – 2012-03-22 10:08:33