D
Darren
Dear Groups,
I am attempting to allow the end user to save or open a pdf document
from the server. However, when the file is downloaded it is not a
pdf, but rather nonsensical garbage. Also, if attempting to save the
file, it only gives the option of file type "text document".
I've run the app on other machines and am fresh out of ideas.
Thanks in advance,
Darren
Code as follows:
Session["FilePath"]=Server.MapPath("../docPDF/") +
e.CommandName.ToString();
Response.ContentType="application/pdf";
Response.AddHeader( "content-disposition","attachment; filename=" +
Session["FilePath"].ToString());
FileStream sourceFile = new
FileStream(@Session["FilePath"].ToString(), FileMode.Open);
long FileSize;
FileSize = sourceFile.Length;
byte[] getContent = new byte[(int)FileSize];
sourceFile.Read(getContent, 0, (int)sourceFile.Length);
sourceFile.Close();
Response.BinaryWrite(getContent);
I am attempting to allow the end user to save or open a pdf document
from the server. However, when the file is downloaded it is not a
pdf, but rather nonsensical garbage. Also, if attempting to save the
file, it only gives the option of file type "text document".
I've run the app on other machines and am fresh out of ideas.
Thanks in advance,
Darren
Code as follows:
Session["FilePath"]=Server.MapPath("../docPDF/") +
e.CommandName.ToString();
Response.ContentType="application/pdf";
Response.AddHeader( "content-disposition","attachment; filename=" +
Session["FilePath"].ToString());
FileStream sourceFile = new
FileStream(@Session["FilePath"].ToString(), FileMode.Open);
long FileSize;
FileSize = sourceFile.Length;
byte[] getContent = new byte[(int)FileSize];
sourceFile.Read(getContent, 0, (int)sourceFile.Length);
sourceFile.Close();
Response.BinaryWrite(getContent);