views:

16

answers:

1

Hello,

I have a directory with a lot of files in it named: file001.pdf, file002.pdf etc.

Now I want a linkbutton in asp.net witch opens one of the above files with an other name!

So for example the linkbutton show's and opens when clicked the pdf: newname.pdf.

Is this possible in asp.net? I only want the client to see the newname.pdf and I want the file001.pdf remains on the server.

Cartes

A: 

You could try reading in the file into a Byte array (or as a stream) and then output the file with a different name?

        Byte[] myFile = System.IO.File.ReadAllBytes("~/MyPdf.pdf");
        Response.ContentType = "application/pdf";
        Response.AppendHeader("content-disposition", "filename=NEW_NAME.pdf");
        Response.OutputStream.Write(myFile, 0, myFile.Length);
        Response.Flush();

Note, not tested this. But it should point you in the right direction...

Jamie Chapman
That's the right direction, thanks a lot!
Cartes