Getting filename with webpage name using Response.WriteFile

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.
 
S

Steve C. Orr [MVP, MCSD]

Use a line like this to specify the filename:
Response.AddHeader("Content-Disposition","attachment;filename=Bobtest.doc");
 
R

Robert Hanson

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.
 
S

Steve C. Orr [MVP, MCSD]

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

Members online

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top