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%時卡住,要等個幾分鐘才結束,也不是每次都這樣,求指導,或者誰給個自己用的順手的下載代碼,謝謝。
這段下載代碼有什么問題嗎
慕田峪9158850
2018-12-07 07:21:12
