We need to open PDF files without showing the URL or downloading the file to the 'downloads' directory.
So we found this but of code to help us do this:
Code to download file (downloadodcs.aspx):
Response.Buffer = false;
Response.BufferOutput = false;
Response.ContentType = "application/pdf";
Stream outstream = Response.OutputStream;
FileStream instream =
new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
byte buffer = new byte;
while ((len = instream.Read(buffer, 0, 10000)) > 0)
outstream.Write(buffer, 0, len);
// served the file -> now delete it
But once it opens one or two PDF's it display's this error in a pop-up box when trying to open another document:
The File is damaged and could not be repaired...
It seems to be filling up the input buffer. And we have tried changing the size of the buffer but it keeps filling up. What am I doing wrong?