读书人

网页显示文件名点击上载

发布时间: 2012-09-21 15:47:26 作者: rapoo

网页显示文件名点击下载
网页上显示指定文件夹中的文件并且点击实现下载。

[解决办法]

HTML code
<a href="文件的具体地址">点击下载</a>
[解决办法]
只能打包下载,B/S好多人都在问能不能批量下载;至今都没好的解决方案。
[解决办法]
C# code
 nP += "<a href=指定下载页面.aspx?path="+finfo[i].FullName+">"+finfo[i].Name+"</a>"+"<br>";然后在下载页面的 pageload中写代码如下        string filePath =Request["path"];//通过URL传过来的参数        FileInfo fileInfo = new FileInfo(filePath);        Response.Clear();        Response.ClearContent();        Response.ClearHeaders();        Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);        Response.AddHeader("Content-Length", fileInfo.Length.ToString());        Response.AddHeader("Content-Transfer-Encoding", "binary");        Response.ContentType = "application/octet-stream";        Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");        Response.WriteFile(fileInfo.FullName);        Response.Flush();        Response.End(); 

读书人网 >asp.net

热点推荐