62,074
社区成员
发帖
与我相关
我的任务
分享
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/vnd.ms-pdf";
HttpContext.Current.Response.AddHeader("Content-disposition", "attachment; filename=" + fileName + ".pdf");
HttpContext.Current.Response.BinaryWrite(bytes);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Close();
try
{
//开始下载 附件
#region
using (EA.Common.IdentityScope c = new EA.Common.IdentityScope(sUsername, sDomain, sPassword))
{
string filename = path + head.AttachmentsPath;
FileStream fs = new FileStream(filename, FileMode.Open);
Stream sw = Response.OutputStream;
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(head.AttachmentsName));
byte[] buf = new byte[256];
int cnt = fs.Read(buf, 0, 256);
while (cnt > 0)
{
sw.Write(buf, 0, cnt);
Response.Flush();
cnt = fs.Read(buf, 0, 256);
}
sw.Close();
fs.Close();
sw.Dispose();
fs.Dispose();
}
Response.Close();
//Response.End();
#endregion
}