日期:2014-05-17 浏览次数:20595 次
/**//// <summary> /// 文件下载 /// </summary> /// <param name= "FullFileName "> </param> private void FileDownload(string FullFileName) ...{ FileInfo DownloadFile = new FileInfo(FullFileName); Response.Clear(); Response.ClearHeaders(); Response.Buffer=false; Response.ContentType= "application/octet-stream "; Response.AppendHeader( "Content-Disposition ", "attachment;filename= " +HttpUtility.UrlEncode(DownloadFile.FullName,System.Text.Encoding.UTF8)); Response.AppendHeader( "Content-Length ",DownloadFile.Length.ToString()); Response.WriteFile(DownloadFile.FullName); Response.Flush(); Response.End(); }
------解决方案--------------------
a标签
------解决方案--------------------
<a href="a.aspx?name=xx.doc">下载</a>
a.aspx里面写上面的代码就可以
FullFileName
参数写
String x = Server.MapPath("~/" + Request.QueryString["name"]);
FileDownload(x);
即可
xx.doc放在程序根目录下
------解决方案--------------------
直接链接文件就可以了
------解决方案--------------------
http://topic.csdn.net/u/20120425/11/21dc8e38-0888-4197-8ff0-a019fd2ffdd7.html