Torna al Thread

public void setResponse(Stream fs, string docname) { if (fs != null) { Response.Clear(); Response.ContentType = "application/pdf"; Response.AddHeader("content-length", fs.Length.ToString()); Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.pdf", docname)); int Length = 256; Byte[] buffer = new Byte[Length]; int bytesRead = fs.Read(buffer, 0, Length); // write the required bytes while (bytesRead > 0) { Response.OutputStream.Write(buffer, 0, bytesRead); bytesRead = fs.Read(buffer, 0, Length); } fs.Close(); Response.Flush(); Response.Close(); } }
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5