[原创]文件下载(WEB)
Private Sub downloadfile(ByVal fileName As String)Dim fileStream As New System.IO.FileStream(fileName, FileMode.Open)
Dim fileSize As Long = fileStream.Length
Dim inta As Integer = CInt(fileSize)
Try
Context.Response.ContentType = "application/octet-stream"
Context.Response.AddHeader("Content-Disposition", "attachment; filename=" & HttpUtility.UrlEncode(fileName, 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()
Catch ex As Exception
Me.ShowAlert1(ex.Message.ToString())
End Try
End Sub