Getting filename with webpage name using Response.WriteFile

  • Thread starter Thread starter Robert Hanson
  • Start date Start date
R

Robert Hanson

Hi All,

I am using the following:

Response.WriteFile(strCompleteFileNameAndPath);

Where the strCompleteFileNameAndPath contains something like
"C:\\SimpleTest\\Bobtest.doc" and the ContentType is Application/msword.
When prompted to save the file, I see the proper file type but the
filename is MyWebpage.doc instead of BobTest.doc.

Any ideas??

Thanks for your help,

Bob Hanson
Centare Group Ltd.
 
Use a line like this to specify the filename:
Response.AddHeader("Content-Disposition","attachment;filename=Bobtest.doc");
 
Thanks Steve,

This worked Great!! Can you please explain what the AddHeader method is
doing so I can have a better understanding?

Thanks again for your help!!

Bob Hanson
Centare Group Ltd.
 
You're giving it the filename that you want it to use, and you're specifying
that you want the document opened externally to the browser. If you want
the document to open up inside the browser you'd specify "inline" instead of
"attachment"
 
Back
Top