473,804 Members | 2,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Downl oad
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\My File.pdf"),
@"C:\Temp\Their File.pdf");

TIA,

John
Nov 18 '05 #1
2 1842
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">Dow nload 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******@YETAN OTHERSPAMHATERc-comld.com> wrote in message
news:eb******** ******@tk2msftn gp13.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.Downl oad 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\My File.pdf"),
@"C:\Temp\Their File.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*****@aboutf ortunate.com> wrote in message
news:10******** *****@corp.supe rnews.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">Dow nload 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******@YETAN OTHERSPAMHATERc-comld.com> wrote in message
news:eb******** ******@tk2msftn gp13.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.Downl oad
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\My File.pdf"),
@"C:\Temp\Their File.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
5836
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 Question ... Presumably, the dialog that you see when you download a binary (asking for a 'Save As...' file name) is put up by your browser when it 'sees' non-text data coming back as a response? So, how would you download a text file - and cause...
0
1836
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 window. Well, thanks to Steve Orr, I have that working. However, I still have a few issues. First, the download dialog does not have the name of the file being downloaded in the "File name" field, instead it has the name of the aspx page that have...
7
3710
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 satisfactory answer (check your browser) so now that I've had the time to set up a reasonable little test that I can post somewhere, I'll try again. The app I've written has three ASPX pages. One is a combined page which writes a little text...
5
3345
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: When I run any of the web apps on my workstations iis website, the pdf download always produces the "File Download" dialog, even though I have Confirm after Download turned off. When I select to Open the file from this dialog the file opens in...
4
2336
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 dialog boxes that says something like "Do you want to download FILEX.txt?" I want the user to be able to download the file rather than have the file displayed in the browser, because the file will include some characters such as tabs and commas....
2
1664
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 = MapPath(e.CommandArgument as string); // Name of file is passed in cmd arg.
4
6270
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
1760
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 dialog know whether the user has clicked on the open button or the save button of the file download dialog??
1
2297
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 machine. This is how I am invoking the file download dialog box that pops up in IE6 (users click a Button): Sub btn_DwnldFile(ByVal obj As Object, ByVal ea As EventArgs) Dim strURL As String = 'getting the file name Response.ContentType =...
1
47495
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 on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10603
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10353
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5675
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.