473,467 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to create a filepath for ftp downloads

I am using WebClient to download a file from a server in my webpage. How can
I create a dialog that asks the client for a download path? Now I am just
hardcoding a directory path for the following command:
myWebClient.DownloadFile(myStringWebResource, fileName);

I guess I am looking for a download version of the FileUpload control.
Anyone know how to do it like the big boys do? Do I need to use javascript?
Nov 3 '06 #1
6 1823
Hi,

Parrot wrote:
I am using WebClient to download a file from a server in my webpage. How can
I create a dialog that asks the client for a download path? Now I am just
hardcoding a directory path for the following command:
myWebClient.DownloadFile(myStringWebResource, fileName);

I guess I am looking for a download version of the FileUpload control.
Anyone know how to do it like the big boys do? Do I need to use javascript?
you don't do this from the server. The simple answer is that you stream
your file down to the client where the client itself (meaning the browser)
will present the FileDialog to the user.

I.e., consider the following:

Response.Clear()
Response.AddHeader("Content-Disposition", "attachment;filename=test.txt")
Response.TransmitFile(Server.MapPath("web.config") )

That will transfer your app's web.config to the browser were the user may
choose to either open it or save it to disk.

Cheers,
Olaf
--
My .02: www.Resources.IntuiDev.com
Nov 3 '06 #2
Hi Olaf;
Thanks for your response. I am now able to download a file from my server
using your suggestion. I added another instruction to indicate the type of
file I am downloading by coding 'Response.ContentType = "application/exe";'
Thanks again for your support.
Dave Uphoff

"Olaf Rabbachin" wrote:
Hi,

Parrot wrote:
I am using WebClient to download a file from a server in my webpage. How can
I create a dialog that asks the client for a download path? Now I am just
hardcoding a directory path for the following command:
myWebClient.DownloadFile(myStringWebResource, fileName);

I guess I am looking for a download version of the FileUpload control.
Anyone know how to do it like the big boys do? Do I need to use javascript?

you don't do this from the server. The simple answer is that you stream
your file down to the client where the client itself (meaning the browser)
will present the FileDialog to the user.

I.e., consider the following:

Response.Clear()
Response.AddHeader("Content-Disposition", "attachment;filename=test.txt")
Response.TransmitFile(Server.MapPath("web.config") )

That will transfer your app's web.config to the browser were the user may
choose to either open it or save it to disk.

Cheers,
Olaf
--
My .02: www.Resources.IntuiDev.com
Nov 3 '06 #3
Olaf;
After downloading my files as you suggested I find that my downloaded files
are corrupted. I cannot open either an exe file or a pdf file. Do you know
what would cause that to happen? Here is my code.

Response.Clear();
Response.ContentType = "application/exe";
Response.AddHeader("Content-Disposition", "attachment;filename="
+ Downloadfile.Text);
string dirpath = Server.MapPath("\\downloads\\" +
Downloadfile.Text);
Response.TransmitFile(dirpath);

Any insight is appreciated. Thnks.

Dave Uphoff

"Olaf Rabbachin" wrote:
Hi,

Parrot wrote:
I am using WebClient to download a file from a server in my webpage. How can
I create a dialog that asks the client for a download path? Now I am just
hardcoding a directory path for the following command:
myWebClient.DownloadFile(myStringWebResource, fileName);

I guess I am looking for a download version of the FileUpload control.
Anyone know how to do it like the big boys do? Do I need to use javascript?

you don't do this from the server. The simple answer is that you stream
your file down to the client where the client itself (meaning the browser)
will present the FileDialog to the user.

I.e., consider the following:

Response.Clear()
Response.AddHeader("Content-Disposition", "attachment;filename=test.txt")
Response.TransmitFile(Server.MapPath("web.config") )

That will transfer your app's web.config to the browser were the user may
choose to either open it or save it to disk.

Cheers,
Olaf
--
My .02: www.Resources.IntuiDev.com
Nov 3 '06 #4
Hi,

Parrot wrote:
After downloading my files as you suggested I find that my downloaded files
are corrupted. I cannot open either an exe file or a pdf file. Do you know
what would cause that to happen? Here is my code.

Response.Clear();
Response.ContentType = "application/exe";
Response.AddHeader("Content-Disposition", "attachment;filename="
+ Downloadfile.Text);
string dirpath = Server.MapPath("\\downloads\\" +
Downloadfile.Text);
Response.TransmitFile(dirpath);
not sure. Check http://support.microsoft.com/kb/902780.
Also, when streaming a PDF you might opt to use "application/pdf" as the
content-type. How large are your files?

Cheers,
Olaf
--
My .02: www.Resources.IntuiDev.com
Nov 4 '06 #5
I tried using "application/pdf" for content.type for a pdf file and it still
creates a corrupted file. I noticed that the downloaded file sizes are
bigger than the original files. It sounds to me like there must be some kind
of bug somewhere. I haven't got a clue as to what to do next. I've tried
using BinaryWrite and WriteFile and I get the same results - a corrupted
file.
Dave

"Olaf Rabbachin" wrote:
Hi,

Parrot wrote:
After downloading my files as you suggested I find that my downloaded files
are corrupted. I cannot open either an exe file or a pdf file. Do you know
what would cause that to happen? Here is my code.

Response.Clear();
Response.ContentType = "application/exe";
Response.AddHeader("Content-Disposition", "attachment;filename="
+ Downloadfile.Text);
string dirpath = Server.MapPath("\\downloads\\" +
Downloadfile.Text);
Response.TransmitFile(dirpath);

not sure. Check http://support.microsoft.com/kb/902780.
Also, when streaming a PDF you might opt to use "application/pdf" as the
content-type. How large are your files?

Cheers,
Olaf
--
My .02: www.Resources.IntuiDev.com
Nov 4 '06 #6
As a follup to the problem of having corrupted files using the TransmitFile
routine, I find that executable programs that are 5 or more years old will
become corrupted whereas recent executables download ok. As for PDF files,
when they are downloaded Acrobat 6.0 kicks in and finds the file corrupted.
However, if I go into the file again with Acrobat 6.0 after the download it
opens ok. I still think there is a buggy situation here because all of the
downloaded files have a bigger file size than the original file. Is
Microsoft listening?

"Parrot" wrote:
I tried using "application/pdf" for content.type for a pdf file and it still
creates a corrupted file. I noticed that the downloaded file sizes are
bigger than the original files. It sounds to me like there must be some kind
of bug somewhere. I haven't got a clue as to what to do next. I've tried
using BinaryWrite and WriteFile and I get the same results - a corrupted
file.
Dave

"Olaf Rabbachin" wrote:
Hi,

Parrot wrote:
After downloading my files as you suggested I find that my downloaded files
are corrupted. I cannot open either an exe file or a pdf file. Do you know
what would cause that to happen? Here is my code.
>
Response.Clear();
Response.ContentType = "application/exe";
Response.AddHeader("Content-Disposition", "attachment;filename="
+ Downloadfile.Text);
string dirpath = Server.MapPath("\\downloads\\" +
Downloadfile.Text);
Response.TransmitFile(dirpath);
not sure. Check http://support.microsoft.com/kb/902780.
Also, when streaming a PDF you might opt to use "application/pdf" as the
content-type. How large are your files?

Cheers,
Olaf
--
My .02: www.Resources.IntuiDev.com
Nov 5 '06 #7

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

Similar topics

0
by: Todd Richardson | last post by:
I have written a web form which downloads files to the client automatically. After the download completes, I would like to delete the file that was downloaded. I can't tell how to wait until the...
3
by: CJA | last post by:
Hi I have a script that will compact an Access MDB and a copy to a new folder. I would it to give each export a unique file name. I can do this with an absolute file reference but I am...
2
by: Karen Sullivan | last post by:
Hi, all. I'm fairly new to SQL, and I have been trying to create a table from a text file. I have been looking at this for days, and can't find the problem. I get a syntax error " Line 55:...
9
by: mjakowlew | last post by:
Hi, I'm trying to use some string manipulation from a file's path. filepath='c:\documents\web\zope\file.ext' I need to extract everthing after the last '\' and save it. I've looked around...
4
by: lwoods | last post by:
I need to create a temporary file on a server. How do I do it? I tried using IO.Path but it created a local file; i.e., file://C:...... TIA, lwoods
1
by: John Wright | last post by:
I want to create a file hash on my exe files and store the hash signature in a database so I can retrieve the value to compare the file hash to ensure I have an untampered file. How can this be...
12
by: snow | last post by:
Hi All, I noticed if file path has a white space, for example "C:\my document \test.txt", the function File.Exists(filePath) always return false in release mode. How could I make this function...
2
by: sebastien.abeille | last post by:
Hello, I would like to create a minimalist file browser using pyGTK. Having read lot of tutorials, it seems to me that that in my case, the best solution is to have a gtk.TreeStore containing...
1
by: TG | last post by:
Hi! I have an application in which I have some checkboxes and depending which ones are checked those columns will show in the datagridview from sql server or no. After that I have 2 buttons:...
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
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...
0
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,...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.