首页 新闻 会员 周边

HttpContext.Current.Response.BinaryWrite 下载文件摘要丢失

0
悬赏园豆:50 [已关闭问题] 关闭于 2010-04-07 00:07
代码
public static void ToDownload(string serverfilpath, string filename)
{
FileStream fileStream
= new FileStream(serverfilpath, FileMode.Open);
long fileSize = fileStream.Length;
HttpContext.Current.Response.ContentType
= "application/octet-stream";
HttpContext.Current.Response.AddHeader(
"Content-Disposition", "attachment; filename=" +UTF_FileName(filename));
////attachment --- 作为附件下载
////inline --- 在线打开
HttpContext.Current.Response.AddHeader("Content-Length", fileSize.ToString());
byte[] fileBuffer = new byte[fileSize];
fileStream.Read(fileBuffer,
0, (int)fileSize);
HttpContext.Current.Response.BinaryWrite(fileBuffer);
fileStream.Close();
HttpContext.Current.Response.End();
}
private static string UTF_FileName(string filename)
{
return (HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8)).Replace("+", "%20");
}

serverfilpath 是文件路径 filename是需要的文件名

文件下载之前用DSOFile修改了摘要,在公司的服务器上是正常的,在自己机器上却是摘要被修改,下载下来的文件竟然没有摘要了?,环境一样,公司的系统补丁少打了点。。

可能是什么原因呢

dd102的主页 dd102 | 初学一级 | 园豆:17
提问于:2010-03-31 23:27
< >
分享
所有回答(1)
0

http://space.cnblogs.com/question/13082/

这是我关于文件下载的问题,我已经解决。

抽时间我整理一下关于文件下载权限控制的方法。

大气象 | 园豆:79 (初学一级) | 2010-04-01 09:36
当时弄错了,文件摘要是存放在ntfs文件流里面的,所以上传下载就没有了,word文件会存在文件里面,所以下载下来读取时会写回属性里面。。
支持(0) 反对(0) dd102 | 园豆:17 (初学一级) | 2010-09-21 22:16
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册