Hi,
I am trying to load a pdf file into a memorystream and upload this file
to the browser. However, wenn I run the attached code (the ftpStream is
a valid stream of the pdf file) I receive an "Application error" in the
Adobe Reader. I tried all the default encodings and the windows
encoding (below) with the same result.
TIA for any hint on what could be wrong here.
Regards
DC
ftpStream.Seek(0, SeekOrigin.Begin);
Response.ClearContent();
Response.ClearHeaders();
Response.BufferOutput = true;
Response.ContentType = "application/pdf";
byte[] buffer = new byte[8192];
int bytesRead = ftpStream.Read(buffer, 0, 8192);
while(bytesRead > 0)
{
char[] charArray =
Encoding.GetEncoding("windows-1252").GetChars(buffer, 0, bytesRead);
Response.Write(charArray, 0, charArray.Length);
bytesRead = ftpStream.Read(buffer, 0, 8192);
}
Response.End();