473,386 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

File download dialog

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
Nov 18 '05 #1
2 1051
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
"John Spiegel" <js******@YETANOTHERSPAMHATERc-comld.com> wrote in message
news:eb**************@tk2msftngp13.phx.gbl...
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

Nov 18 '05 #2
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.

"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:10*************@corp.supernews.com...
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
"John Spiegel" <js******@YETANOTHERSPAMHATERc-comld.com> wrote in message
news:eb**************@tk2msftngp13.phx.gbl...
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


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: peetm | last post by:
I'd like to write to a log whenever a visitor to my site downloads a file. So, I'd like the link they click to be to a php 'page' that returns the file. Don't know how to do that! Side...
0
by: Buddy Ackerman | last post by:
I am trying to implment a file download via a link such that when clicked, instead of starting the default application for that type of file the user will be presented with a download dialog...
7
by: theyas | last post by:
How can I get my code to NOT display two "Open/Save/Cancel/More Info" dialog boxes when using the "Response.WriteFile" method to download a file to IE I've asked about this before and didn't get a...
5
by: Brad | last post by:
In several aspx applications I export crytal reports to pdf, xls and doc files and then the aspx page writes the selected export file to the client browser. This all works with one small quirk: ...
4
by: Nathan Sokalski | last post by:
I want to give visitors to my site the option of downloading a generated ..txt file by clicking a button. I know how to generate text files, but how do I cause the browser to pop up one of those...
2
by: Ken Varn | last post by:
I have an ASP.NET page that incorporates the following code on a button press. private void DownloadTag_Command(object sender, CommandEventArgs e) { FileStream fs; String Filename; Filename...
4
by: Jonny | last post by:
Hello Group How do I open a Save File Dialog from an ASPX page behind a browse button? Any help would be fantastic!! I am using ASP.NET 1.1 using VB.NET as the coding language TIA
1
by: sunita | last post by:
Hiii I open a file download dialog from a modal dialog...From the file download dialog i can either save or open the file.. Is there a way i can let the modal dialog that opens the file download...
1
by: RN1 | last post by:
In an ASP.NET app, users can upload their files to a remote server as back-up. I want to give users the provision to download files that they have uploaded to the remote server to their local...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.