下载文件 application/octetstream (VB.NET)

        Dim SMS_UploadFiles_Path As String = System.Configuration.ConfigurationSettings.AppSettings("SMS_UploadFiles_Path")
        'Dim mPath As String = Server.MapPath(SMS_UploadFiles_Path) + "\"
        Dim mPath As String = ""
        If SMS_UploadFiles_Path.EndsWith("\") = False Then
            mPath = SMS_UploadFiles_Path + "\"
        Else
            mPath = SMS_UploadFiles_Path
        End If
 
        Dim str_att As String = Request.QueryString("att")
        Dim str_oatt As String = Request.QueryString("oatt")

        Dim extandName As String = Path.GetExtension(str_oatt)
        Dim fileName As String = Path.GetFileNameWithoutExtension(str_oatt)

        If (fileName.Length > 12) Then
            fileName = fileName.Substring(0, 12)
        End If

Response.Clear()
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Disposition", "attachment; filename=" & HttpUtility.UrlEncode(fileName) & extandName)
Response.WriteFile(mPath + str_att)

原文地址:https://www.cnblogs.com/RobotTech/p/533653.html