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();
}
}