downloading file

R

roland.groenvynck

I try to build my first web form application with C#.
I want to program the downloading of a file to the client .
Therefore I can use WebClient.DownloadFile (url, filepath );

I would like that the user is able to select the directory(on his
machine) with a kind of a control ?

How can I do that?

many thanks for helping me
 
B

Bruce Barker

are you building a webform application, or a winform? in a webform app,
WebClient would be used by the server to fetch a file from another server.
in a winform app (one run on the client machine), WebClient can be used to
talk to a webserver.

in a webform app, you allow downloads by supplying a link to the file.

<a href="mydownload.aspx">click here to download</a>


-- bruce (sqlwork.com)
 
R

roland.groenvynck

I try to realise my first asp.net web application . Si I have a webform
with buttons where the user can click to download a file from my site.

I did use this code as part as a handler of a button: :

WebClient wc= new WebClient();
wc.DownloadFile (url,"d:\\test");

that works. But now I wish that the user could decide where to donwload
the file on his machine .
So this code has to fill the value of a string variable:

string pathname;

and Icould download by the means of:

wc.DownloadFile (url,"pathname\\test");

So my question is , what is the code to fill pathname

many thanks




string pathOnClient
 
P

Patrice

Remember that this is server side code, that is you are actually downloading
to the server disk. Though it may appear to work when working on localhost
try this on a remote server...

For a webform I would just use a link.

If you want to stream you could use :
http://support.microsoft.com/kb/260519/en-us
to force the download dialog (which let the user to open or save the file at
a particular location).

(with Response.WriteFile if the file isn't too big to stream the file to the
browser).
 
J

Joerg Jooss

Thus wrote (e-mail address removed),
I try to build my first web form application with C#.
I want to program the downloading of a file to the client .
Therefore I can use WebClient.DownloadFile (url, filepath );
I would like that the user is able to select the directory(on his
machine) with a kind of a control ?

How can I do that?

Are you trying to download a file from another server (e.g. Client<-->YourServer<-->AnotherServer)
or directly from your server? In the latter case, you don't need WebClient.

Cheers,
 

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,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top