dudo博客

8月
05

文件下载的写法

Filed Under (网站开发) by dudo

        Dim FileName As String = "D:\DoctorEnrollDocs\" & Session("ID") & ".doc"
        Dim FileStream As New FileStream(FileName, FileMode.Open)
        Dim FileSize As Long = FileStream.Length
        Dim inta As Int32 = CInt(FileSize)
       
        Context.Response.ContentType = "application/octet-stream"
        Context.Response.AddHeader("Content-Disposition", "attachment; filename=" & HttpUtility.UrlEncode("东北大学博士生入考试报名表" & ".doc", System.Text.Encoding.UTF8))
        Context.Response.AddHeader("Content-Length", FileSize.ToString())
        Dim fileBuffer(inta) As Byte
        FileStream.Read(fileBuffer, 0, inta)
        FileStream.Close()
        Context.Response.BinaryWrite(fileBuffer)
        Context.Response.End()



随便说两句
名字:
Email:
网站:
内容:

无觅相关文章插件,快速提升流量