从服务器下载文件的方法
2008-11-28 17:08
106 查看
public static void DownloadFile(string physicalFilePath){ FileStream stream=null; stream = new FileStream(physicalFilePath, FileMode.Open, FileAccess.Read, FileShare.Read); int bufSize = (int)stream.Length; byte[] buf = new byte[bufSize]; int bytesRead = stream.Read(buf, 0, bufSize); HttpContext.Current.Response.ContentType = "application/octet-stream"; HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename="+System.IO.Path.GetFileName(physicalFilePath)); HttpContext.Current.Response.OutputStream.Write(buf, 0, bytesRead); HttpContext.Current.Response.End();}
相关文章推荐
- 经验分享] 向云服务器上传下载文件方法汇总
- 向云服务器上传下载文件方法汇总
- 让服务器iis支持.apk文件下载的设置方法
- win2003服务器允许下载.exe文件的方法
- java方法客户端下载服务器上的文件到本地
- 向云服务器上传下载文件方法汇总
- Java实现ftp上传下载、删除文件及在ftp服务器上传文件夹的方法
- python实现从ftp服务器下载文件的方法
- python实现从ftp服务器下载文件的方法
- 让服务器iis支持.apk文件下载的设置方法
- 关于从WEB服务器自动下载安装可执行性文件的方法
- 让服务器iis支持.apk文件下载的设置方法
- web端下载服务器上的文件,js方法下载
- php实现远程网络文件下载到服务器指定目录(方法一)
- 让服务器iis支持.apk文件下载的设置方法
- 让服务器iis支持.apk文件下载的设置方法
- nginx服务器在IE下载时,apk,ipa文件变成zip的解决方法
- u-boot通过nfs从服务器下载内核,并且启动内核,挂载根文件系统的方法
- 让服务器iis支持.apk文件下载的设置方法
- JSP下载服务器文件的方法