标题: 怎样输出 图片 下载?
- 卡卡.net 2005-08-28 13:29 阅读:1318
- 评论:2 查看评论 | 添加评论

ASP.NET可以直接输出文件下载,例如doc,zip,rar这类IIS不能解释的格式,如果是Bmp,Gif,Jepg就不行了,怎样实现其下载呢(出现保存那个对话框)?

[图片]    // Identify the file to download including its path.
[图片]    string filepath = DownloadFileName;
[图片]
[图片]    // Identify the file name.
[图片]    string filename = System.IO.Path.GetFileName(filepath);
[图片]
[图片]    Response.Clear();
[图片]
[图片]    // Specify the Type of the downloadable file.
[图片]    Response.ContentType = "application/octet-stream";
[图片]
[图片]    // Set the Default file name in the FileDownload dialog box.
[图片]    Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
[图片]
[图片]    Response.Flush();
[图片]
[图片]    // Download the file.
[图片]    Response.WriteFile(filepath);

看了http://www.cnblogs.com/koffer/archive/2004/10/14/52289.htmlt也没有发现答案! 

BTW:Response.WriteFile 无法下载大文件
查看评论 | 添加评论
返回顶部 | 返回首页