Can I Response.Redirect to a pdf file on my c: drive?

D

Dave

I have a Crystal reports export that throws the exported pdf file into a
folder c:\reports. The export works fine, but now I need to redirect the
user to that report. Can you please tell me how I can do that?

Thanks,

-Dave
 
I

Isaias Formacio-Serna

This code works perfectly for me:



Response.ContentType="application/pdf";

Response.AddHeader( "content-disposition","attachment; filename=filename);

FileStream sourceFile = new FileStream("C:\\PDFs\\" + filename,
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);

-IFS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top