困扰了我好久的问题,终于得以解决
- Dim strFile As String = $your file name$
- Response.Clear()
- Response.ClearHeaders()
- Response.Charset = "GB2312"
- Response.ContentEncoding = System.Text.Encoding.UTF8
- Response.ContentType = "application/octet-stream"
- Dim fi As New FileInfo(strFile)
- Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fi.Name))
- Response.AddHeader("Content-Length", fi.Length.ToString())
- Dim arrayLength As Long = fi.Length
- Dim tmpbyte(arrayLength) As Byte
- Dim fs As FileStream = fi.OpenRead()
- While fs.Read(tmpbyte, 0, CInt(arrayLength)) > 0
- Response.BinaryWrite(tmpbyte)
- Response.Flush()
- End While
- fs.Close()
- Response.End()