try
{
string filepath = context.Server.MapPath(context.Request.QueryString["filedir"].ToString() + "/" + context.Request.QueryString[0].Substring(0, 4).ToString() + "/" + context.Request.QueryString[0].ToString());
string filename = context.Request.QueryString[1].ToString();
FileInfo info = new FileInfo(filepath);
long fileSize = info.Length;
context.Response.Clear();
context.Response.ContentType = "application/x-zip-compressed";
context.Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8));
//不指明Content-Length用Flush的话不会显示下载进度
context.Response.AddHeader("Content-Length", fileSize.ToString());
context.Response.TransmitFile(filepath, 0, fileSize);
context.Response.Flush();
context.Response.Close();
}
catch
{ }
为什么会在99%时卡住,要等个几分钟才结束,也不是每次都这样,求指导,或者谁给个自己用的顺手的下载代码,谢谢。
4 回答
- 4 回答
- 0 关注
- 348 浏览
添加回答
举报
0/150
提交
取消