在一个aspx页面中在page_load中用如下代码
[code]
//fileUrl是文件在服务器上的物理路径,可以通过Server.MapPath(virtualPath)获得
System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileURL);
Response.Clear();
Response.AddHeader("content-disposition","attachment;filename="+Server.UrlEncode(fileInfo.Name.ToString()));
Response.AddHeader("content-length",fileInfo.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.ContentEncoding = System.Text.Encoding.Default;
Response.WriteFile(fileURL);
[/code]
玉开
|
大侠五级
|园豆:8822
|
2008-06-03 09:17