Downloading a file...

I

Ian Gordon

Hi,

I have 2 problems when downloading a file from my ASP.net app to the client
PC. At the moment I'm doing it with the following code:

Response.ContentType = "application/octet-stream"

Response.AddHeader("Content-Disposition", "attachment; filename=" +
strFileToDownload)

Response.WriteFile(strFileToDownload)



The problems are:
1. How can I set the name of document to be downloaded? At the moment, the
name of file is by default set to be the name of the web form that it comes
from, which is far from ideal. to be able to call it, for example,
myFile.doc.
2. How can I try and force the save to be in a specific directory, or even
to default to the Windows temp directory, or to My Documents? At the moment,
the default target directory seems quite different on different machines.

All help very much appreciated.

Ian
(e-mail address removed)
 

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,997
Messages
2,570,241
Members
46,832
Latest member
UtaHetrick

Latest Threads

Top