需要下载服务器上word文件
在按钮事件中怎么写程序?

解决方案 »

  1.   

    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
      

  2.   

    http://topic.csdn.net/u/20080103/12/11958e2c-d058-4811-b348-2f4b11829763.html
    上面的网址我回答得很详细了.