惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
C
CERT Recently Published Vulnerability Notes
人人都是产品经理
人人都是产品经理
V
Visual Studio Blog
大猫的无限游戏
大猫的无限游戏
月光博客
月光博客
L
LangChain Blog
J
Java Code Geeks
B
Blog
博客园_首页
Engineering at Meta
Engineering at Meta
宝玉的分享
宝玉的分享
D
Docker
L
LINUX DO - 最新话题
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
Microsoft Security Blog
Microsoft Security Blog
Scott Helme
Scott Helme
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Blog of Author Tim Ferriss
U
Unit 42
T
Tenable Blog
F
Fortinet All Blogs
K
Kaspersky official blog
博客园 - 【当耐特】
T
Tailwind CSS Blog
Y
Y Combinator Blog
C
Check Point Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The Hacker News
The Hacker News
美团技术团队
S
Schneier on Security
P
Proofpoint News Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Proofpoint News Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Microsoft Azure Blog
Microsoft Azure Blog
MongoDB | Blog
MongoDB | Blog
Cisco Talos Blog
Cisco Talos Blog
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
NISL@THU
NISL@THU
T
The Exploit Database - CXSecurity.com
L
Lohrmann on Cybersecurity
Martin Fowler
Martin Fowler
Blog — PlanetScale
Blog — PlanetScale
酷 壳 – CoolShell
酷 壳 – CoolShell
The Cloudflare Blog
I
Intezer
有赞技术团队
有赞技术团队

博客园 - 落尘

.NET上传图片加文字和水印图片源码 - 落尘 - 博客园 ASP.NET下的多文件上传 ASP.NET 2.0 多文件上传小经验 文件的上传和下载 在ASP.NET程序中实现语音合成 .Net平台下开发中文语音应用程序 语音合成与识别技术在C#中的应用 如何防止ASP 木马在服务器上运行 用ASP实现在线压缩与解压缩 asp对象化之:基于adodb.stream的文件操作类 js鼠标及对象坐标控制属性 NET中各种数据库连接大全 几个ASP.NET技巧 设计ASP.NET应用程序的七大绝招 ASP.NET中如何调用存储过程 Asp.net cache 简述 如何用C#把Doc文档转换成rtf格式 单点登陆 硬盘双击无法打开是咋回事
Asp.net直接保存文件到客户端
落尘 · 2006-11-26 · via 博客园 - 落尘

1 /**//// <summary>
2 /// 下载文件
3 /// </summary>
4 /// <param name="filename">文件物理地址</param>
5 protected void DownloadFile(string filename)
6 {
7
8 string saveFileName = "test.xls";
9 int intStart = filename.LastIndexOf("\\")+1;
10 saveFileName = filename.Substring(intStart,filename.Length-intStart);
11
12 System.IO.FileInfo fi=new System.IO.FileInfo(filename);
13 string fileextname=fi.Extension;
14 string DEFAULT_CONTENT_TYPE = "application/unknown";
15 RegistryKey regkey,fileextkey;
16 string filecontenttype;
17 try
18 {
19 regkey=Registry.ClassesRoot;
20 fileextkey=regkey.OpenSubKey(fileextname);
21 filecontenttype=fileextkey.GetValue("Content Type",DEFAULT_CONTENT_TYPE).ToString();
22 }
23 catch
24 {
25 filecontenttype=DEFAULT_CONTENT_TYPE;
26 }
27
28
29 Response.Clear();
30 Response.Charset = "utf-8";
31 Response.Buffer= true;
32 this.EnableViewState = false;
33 Response.ContentEncoding = System.Text.Encoding.UTF8;
34
35 Response.AppendHeader("Content-Disposition","attachment;filename=" + saveFileName);
36 Response.ContentType=filecontenttype;
37
38 Response.WriteFile(filename);
39 Response.Flush();
40 Response.Close();
41
42 Response.End();
43 }

posted on 2006-11-26 14:47  落尘  阅读(243)  评论()    收藏  举报