下载文件 application/octet-stream (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)

posted @ 2006-10-19 14:43  RobotTech  阅读(6728)  评论(27编辑  收藏  举报