日期:2014-05-18  浏览次数:20443 次

asp.net下载问题
我想通过linkbutton点击下载,如下是我的代码:

 Dim Filepath As String = Label7.Text
  Dim fileStream As New FileStream(Filepath, FileMode.Open)
  Dim fileSize As Long = fileStream.Length
  Dim inta As Integer = CInt(fileSize)
  Dim OutPutFileName As String = " 121.txt"[i][/i]
  Response.ContentType = "application/octet-stream"
  Response.AddHeader("Content-Disposition", "attachment; filename=" & HttpUtility.UrlEncode(OutPutFileName, System.Text.Encoding.UTF8))
  Response.AddHeader("Content-Length", fileSize.ToString())
  Dim fileBuffer(inta) As Byte
  fileStream.Read(fileBuffer, 0, inta)
  fileStream.Close()
  Response.BinaryWrite(fileBuffer)
  Response.End()
在下载的时候上面加黑的地方一定要写成文档的名字,不能修改成其它代替吗?

------解决方案--------------------
可以的,它是展示在下载提示框上的名字
------解决方案--------------------
楼上已回答,不多说了。补充就是如果是中文注意编码