标题:关于写文件下载的问题
只看楼主
yinniannian
Rank: 9Rank: 9Rank: 9
来 自:河北省石家庄
等 级:蜘蛛侠
威 望:2
帖 子:256
专家分:1007
注 册:2011-5-13
结帖率:92.86%
已结贴  问题点数:0 回复次数:1 
关于写文件下载的问题
小弟菜鸟,我想写一个文件下载的程序,现在功能已经实习,代码如下

int index = Convert.ToInt32();//取得当前行
FileInfo downLoadFile = new FileInfo(GridView1.Rows[index].Cells[1].Text);
Response.ContentType = "application/octet-stream";
string fileName = HttpUtility.UrlEncode(GridView1.Rows[index].Cells[0].Text, System.Text.Encoding.UTF8);//防止中文名称时的乱码
Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
Response.AppendHeader("Content-length", downLoadFile.Length.ToString());
Response.WriteFile(downLoadFile.FullName);
Response.Flush();
Response.End();

但是对Response的AddHeader不是太了解,望高手指教
搜索更多相关主题的帖子: 中文 index 文件下载 
2011-08-25 11:40
heliyi
Rank: 4
来 自:安徽省黄册市
等 级:业余侠客
帖 子:44
专家分:260
注 册:2011-7-29
得分:20 
指定文件名称,告诉浏览器文件大小
2011-08-25 23:23



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-348370-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.802979 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved