我上传了一个WORD文件到d盘 d:\mydoc\111.doc 请问如何通过程序下载下来呢? 我上传了一个WORD文件到d盘 d:\mydoc\111.doc 请问如何通过程序下载下来呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public static void DownloadFile(string physicalFilePath){ FileStream stream=null; try { 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(); } finally { stream.Close(); }}private void btndownload_Click(object sender, System.EventArgs e){ DownloadFile(@"d:\mydoc\111.doc"); } C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -iC:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -c IE8 不认识输出流?!context.Response.OutputStream?? 表格布局问题 急急急!!!帮帮我 cs程序获取URL地址中带#的问题 求一JS替换的正则表达式 VS2003 C# 发送邮件老是失败,郁闷之极~~~! .net关于获取地址栏的问题 怎么在子页面的后台获取showModalDialog传过来的参数(在线等)? 在global文件里不能用操作数据库么 用程序动态的控制现实的内容怎么做? 上传PDF文件到网站上去,然后转换为电子书效果显示 .net项目中sql触发器问题 为什么它在桌面应用中可以运行成功而在WEB应用中在运行时报错
{
FileStream stream=null;
try
{
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();
}
finally
{
stream.Close();
}
}private void btndownload_Click(object sender, System.EventArgs e)
{
DownloadFile(@"d:\mydoc\111.doc");
}
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -c