Downloading a file...

  • Thread starter Thread starter Ian Gordon
  • Start date Start date
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)
 
Hi Ian,

Bill P.has replied your post in <microsoft.public.dotnet.framework.aspnet>
titled:<Downloading a file to client>.

Please post here if the problem is not resolved. Thanks.


Best Regards,
Lewis

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| From: "Ian Gordon" <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework
| Subject: Downloading a file...
| Lines: 27
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| Message-ID: <[email protected]>
| Date: Wed, 30 Jul 2003 22:16:45 +0100
| NNTP-Posting-Host: 194.112.59.182
| X-Complaints-To: (e-mail address removed)
| X-Trace: news.dircon.co.uk 1059599674 194.112.59.182 (Wed, 30 Jul 2003
22:14:34 BST)
| NNTP-Posting-Date: Wed, 30 Jul 2003 22:14:34 BST
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!newsfee
d01.sul.t-online.de!t-online.de!feed.news.nacamar.de!newsfeed.icl.net!newsfe
ed.fjserv.net!peer1.news.dircon.net!peer2.news.dircon.net!news.dircon.co.uk.
POSTED!not-for-mail
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework:50174
| X-Tomcat-NG: microsoft.public.dotnet.framework
|
| 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)
|
|
|
 
Back
Top