By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,304 Members | 3,174 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,304 IT Pros & Developers. It's quick & easy.

downloading file

P: n/a
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

Mar 14 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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)

<ro***************@pandora.be> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.com...
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

Mar 14 '06 #2

P: n/a
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

Mar 14 '06 #3

P: n/a
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).

--
Patrice

<ro***************@pandora.be> a écrit dans le message de
news:11**********************@e56g2000cwe.googlegr oups.com...
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

Mar 14 '06 #4

P: n/a
Thus wrote ro***************@pandora.be,
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,
--
Joerg Jooss
ne********@joergjooss.de
Mar 14 '06 #5

P: n/a
Thanks!!!!! it helped me a lot !!

Mar 14 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.