File download dialog

J

John Spiegel

Hi all,

How does one allow a user to download a file WITH selecting where it should
be downloaded to on their machine? Also, when using the WebClient.Download
method, will the destination path written in Windows format (backslashes,
etc.) translate across client platforms? Is there a better way?

WebClient wc = new WebClient();
wc.DownloadFile(Server.MapPath(@"Downloads\MyFile.pdf"),
@"C:\Temp\TheirFile.pdf");

TIA,

John
 
S

S. Justin Gengo

John,

The easiest way to do what you are asking is to just create a link on the
page pointing to the file to download. (e.g. <a
href="Downloads/MyFile.pdf">Download MyFile.pdf</a>)

A link such as this will open a dialog box which will allow a user to open
or save the file. If they choose save then a dialog box allowing them to
choose where to save the file will open.

Since in your example you are using a .pdf file you should also know that,
depending on the way a user's adobe acrobat reader program is set up the
file may open in the browser window automatically. However, if they choose
file - save from the menu they will be able to save the downloaded file
wherever they want on their drive.

I hope this helps.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
J

John Spiegel

Sheesh. So simple, but I couldn't see the forest through the trees!
Thanks!

- John

Please note: I am not as irretrievably stupid as some of my questions might
make me appear.
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top