如何把服务器上的文件下载到客户端呢? <a href="你的文件路径">下载</a> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 大致如下,請參考:FileStream fs = new FileStream("絕對路徑", FileMode.Open, FileAccess.Read);BinaryReader r= new BinaryReader(fs);Response.Buffer=true;Response.AddHeader("Content-Disposition", "attachment; filename=文件名");Response.Charset = "GB2312";Response.ContentType = "application/octet-stream";Response.BinaryWrite(r.ReadBytes(Convert.ToInt32(fs.Length)));Response.Flush() ; http://blog.csdn.net/lxs5i5j/archive/2007/02/02/1500790.aspx 试试这个 string createPath = Server.MapPath("../" + FilePath);//FilePath服务器上文件相对路径 FileInfo DownloadFile = new FileInfo(createPath); Response.Clear(); Response.ClearHeaders(); Response.Buffer = true; Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(FileName));//FileName带扩展名的文件名 Response.AddHeader("Content-Length ", DownloadFile.Length.ToString()); Response.TransmitFile(createPath); Response.Flush(); Response.End(); 参考微软的讲解:http://www.microsoft.com/china/msdn/library/webservices/asp.net/WebDownloads.mspx?mfr=true 如何将iframe作为一个弹出层? 白痴问题,如何控制实体类字段的顺序 如何用正则替换内容的关键字 谁有漂亮点的TreeView样式图片,发几张来看看 JavaScript和ASP.NET传值问题``在线等啊! 资源文件的使用? asp.net读取不了 图片文件的问题,急求助 好心人进来看看,问个ActiveX问题 使用oledb 连接mssql server数据库。。碰到对方把端口改了。。连接串怎么连呢? DATAGRID在编辑模式问题!! .net 开发模式 我想在数据库没有数据的情况下,在页面上面保留GridView标头并下面有一行显示提示用户添加新的数据(ASP.NET)
BinaryReader r= new BinaryReader(fs);
Response.Buffer=true;
Response.AddHeader("Content-Disposition", "attachment; filename=文件名");
Response.Charset = "GB2312";
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(r.ReadBytes(Convert.ToInt32(fs.Length)));
Response.Flush() ;
string createPath = Server.MapPath("../" + FilePath);//FilePath服务器上文件相对路径
FileInfo DownloadFile = new FileInfo(createPath);
Response.Clear();
Response.ClearHeaders();
Response.Buffer = true;
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(FileName));//FileName带扩展名的文件名
Response.AddHeader("Content-Length ", DownloadFile.Length.ToString());
Response.TransmitFile(createPath);
Response.Flush();
Response.End();
http://www.microsoft.com/china/msdn/library/webservices/asp.net/WebDownloads.mspx?mfr=true