FileInfo DownloadFile = new FileInfo("c:\\a.doc");
// 下面到就是读取文件,通过数据流的方式下载了。
Response.Clear();
Response.ClearHeaders();
Response.Buffer = false;
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "inline;filename=" + HttpUtility.UrlEncode("c:\\a.doc", System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
Response.Flush();
Response.End();
Content-Disposition:inline是直接打开,attachment是保存。