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"
 

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

Back
Top