.net 网页开发中如何用代码实现下载功能 我们在开发网站的时候,要为用户提供一个下载的功能,用户主要是通过浏览网站时,在些网站上下载,这个效果怎么现实。代码要详细的说明。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 /**//// <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 href="a?name=">下载</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 asp.net cookie 中文乱码 每个会员有一个独立的网址:如Web:www.xxxx.com/000000001 如何实现? 关于自定义登陆页面的问题 用sql来控制treeview的问题,高分请请回答 GridView中行列合并的问题,比如我想把这一列中内容相同的单元格合并。该怎么合并?? 想找个代码 DataGrid中的checkbox如何一次全部选择 发布web应用程序的必要条件是什么? 现在最流行的技术是什么? 请教一个网站合理的后台管理是如何写的?说说思路 label控件调用 非常奇怪的问题,请大家帮下忙,asp.net页面回发时找不到Cookie,
/**//// <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();
}
FullFileName
参数写
String x = Server.MapPath("~/" + Request.QueryString["name"]);
FileDownload(x);
即可
xx.doc放在程序根目录下