string fileName = "【下载】" + filename//客户端保存的文件名
string filePath = System.Web.HttpContext.Current.Request.MapPath("~/UpFile/TraceCode/" + filename + "")//路径
FileStream fileStream = new FileStream(filePath, FileMode.Open)
byte[] bytes = new byte[(int)fileStream.Length]
fileStream.Read(bytes, 0, bytes.Length)
fileStream.Close()
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream"
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachmentfilename=" + fileName)
System.Web.HttpContext.Current.Response.BinaryWrite(bytes)
System.Web.HttpContext.Current.Response.Flush()
//System.Web.HttpContext.Current.Response.End()
//System.Web.HttpContext.Current.Response.Close()
System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)