复制代码 代码如下:
Shared Function DownloadFile(ByVal WebForm As System.Web.UI.Page, ByVal FileNameWhenUserDownload As String, ByVal FileBody As String)
WebForm.Response.ClearHeaders()
WebForm.Response.Clear()
WebForm.Response.Expires = 0
WebForm.Response.Buffer = True
WebForm.Response.AddHeader("Accept-Language", "zh-tw")
'文件名称
WebForm.Response.AddHeader("content-disposition", "attachment; filename=" & Chr(34) & System.Web.HttpUtility.UrlEncode(FileNameWhenUserDownload, System.Text.Encoding.UTF8) & Chr(34))
WebForm.Response.ContentType = "Application/octet-stream"
'文件内容
WebForm.Response.Write(FileBody)
WebForm.Response.End()
End Function
复制代码 代码如下:
Shared Sub DownloadFile(ByVal WebForm As System.Web.UI.Page, ByVal FileNameWhenUserDownload As String, ByVal FilePath As String)
WebForm.Response.ClearHeaders()
WebForm.Response.Clear()
WebForm.Response.Expires = 0
WebForm.Response.Buffer = True
WebForm.Response.AddHeader("Accept-Language", "zh-tw")
'文件名称
WebForm.Response.AddHeader("content-disposition", "attachment; filename=" & Chr(34) & System.Web.HttpUtility.UrlEncode(FileNameWhenUserDownload, System.Text.Encoding.UTF8) & Chr(34))
WebForm.Response.ContentType = "Application/octet-stream"
'文件内容
WebForm.Response.Write(System.IO.File.ReadAllBytes(FilePath))
WebForm.Response.End()
End Sub
新闻热点
疑难解答
图片精选