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

<a href=file\\\f:\*rar />该怎么处理

2012-01-29 
a hreffile\\\f:\***.rar /a hreffile\\\f:\***.rar /在程序中不能连接到磁盘上的文件 有什么办法能

<a href=file\\\f:\***.rar />
<a href=file\\\f:\***.rar />在程序中不能连接到磁盘上的文件 有什么办法能解决这个问题

[解决办法]
用服务器程序做中转,二进制输出下载
ContentType="application/octet-stream"

[解决办法]

private void Page_Load(object sender, System.EventArgs e)
{
string FilePath = Request.QueryString["FilePath"]; //文件物理路径
using (System.IO.FileStream fs = new System.IO.FileStream(FilePath,System.IO.FileMode.Open))
{
byte[] byteBuffer = new byte[fs.Length];
fs.Read(byteBuffer,0,byteBuffer.Length);
Response.AddHeader("Content-Disposition", "attachment; filename="+System.IO.Path.GetFileName(FilePath));
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(byteBuffer);
Response.Flush();
}
}

<a href="down.aspx?filepath=f:\***.rar" / >

热点排行