.net问题,高手解答
StringFullFileName=System.Web.HttpContext.Current.Server.MapPath(FileName);FileInfoDo...
String FullFileName = System.Web.HttpContext.Current.Server.MapPath(FileName);
FileInfo DownloadFile = new FileInfo(FullFileName);
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.ClearHeaders();
System.Web.HttpContext.Current.Response.Buffer = false;
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));
System.Web.HttpContext.Current.Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
System.Web.HttpContext.Current.Response.WriteFile(DownloadFile.FullName);
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.End();
上面那段代码是什么意思,希望高手能一句一句的解释,谢谢
我希望能一句句的翻译,谢谢 展开
FileInfo DownloadFile = new FileInfo(FullFileName);
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.ClearHeaders();
System.Web.HttpContext.Current.Response.Buffer = false;
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));
System.Web.HttpContext.Current.Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
System.Web.HttpContext.Current.Response.WriteFile(DownloadFile.FullName);
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.End();
上面那段代码是什么意思,希望高手能一句一句的解释,谢谢
我希望能一句句的翻译,谢谢 展开
2个回答
展开全部
//获取文件FileName的全路径
String FullFileName = System.Web.HttpContext.Current.Server.MapPath(FileName);
//通过该文件得到一个fileinfo实例,以便访问该文件
FileInfo DownloadFile = new FileInfo(FullFileName);
//清空页面输出流
System.Web.HttpContext.Current.Response.Clear();
//清空页面header
System.Web.HttpContext.Current.Response.ClearHeaders();
//禁止缓冲输出
System.Web.HttpContext.Current.Response.Buffer = false;
//指示输出流格式
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
//为输出添加http头(添加一个附件)
System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));
//输出流长度
System.Web.HttpContext.Current.Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
//将文件写入当前输出流
System.Web.HttpContext.Current.Response.WriteFile(DownloadFile.FullName);
//发送所有缓冲的输出
System.Web.HttpContext.Current.Response.Flush();
//结束输出
System.Web.HttpContext.Current.Response.End();
String FullFileName = System.Web.HttpContext.Current.Server.MapPath(FileName);
//通过该文件得到一个fileinfo实例,以便访问该文件
FileInfo DownloadFile = new FileInfo(FullFileName);
//清空页面输出流
System.Web.HttpContext.Current.Response.Clear();
//清空页面header
System.Web.HttpContext.Current.Response.ClearHeaders();
//禁止缓冲输出
System.Web.HttpContext.Current.Response.Buffer = false;
//指示输出流格式
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
//为输出添加http头(添加一个附件)
System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));
//输出流长度
System.Web.HttpContext.Current.Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
//将文件写入当前输出流
System.Web.HttpContext.Current.Response.WriteFile(DownloadFile.FullName);
//发送所有缓冲的输出
System.Web.HttpContext.Current.Response.Flush();
//结束输出
System.Web.HttpContext.Current.Response.End();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询