首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

网页显示文件名点击上载

2012-09-21 
网页显示文件名点击下载网页上显示指定文件夹中的文件并且点击实现下载。[解决办法]HTML codea href文件

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

[解决办法]

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(); 

热点排行