在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
Try
Dim pdf As String = "./Files/ty1.pdf" pdf = Server.MapPath(pdf) 'read all bytes If File.Exists(pdf) = False Then Throw New Exception("This report is not created") End If Dim fs As FileStream = File.Open(pdf, FileMode.Open) Dim buffer() As Byte = New Byte(fs.Length) {} fs.Read(buffer, 0, buffer.Length) fs.Close() 'write to response Response.Clear() Response.ContentType = "application/pdf" Response.AddHeader("content-disposition", "filename=ty1.pdf") Response.AddHeader("content-length", buffer.Length.ToString()) Response.BinaryWrite(buffer) Response.End() Catch ex As Exception End Try
一定要装PDF阅读器,否者是读不出来的 |
请发表评论