How to create a filepath for ftp downloads

G

Guest

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?
 
O

Olaf Rabbachin

Hi,
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
 
G

Guest

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
 
G

Guest

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
 
O

Olaf Rabbachin

Hi,
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
 
G

Guest

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
 
G

Guest

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?
 

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,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top