Groups | Blog | Home
all groups > dotnet faqs > december 2003 >

dotnet faqs : Downloading a file from a website



Scott M.
12/17/2003 10:31:30 PM
What do you want to do? You don't need .NET for that. <A
HREF="file.ext">Click to download</A>


"Chris Morrison"
<chris-[NO-SPAM]morrison@rassalom-[SPAM_BLOCK]technology.co.uk> wrote in
message news:eoUuXCRxDHA.2652@TK2MSFTNGP09.phx.gbl...
[quoted text, click to view]

Chris Morrison
12/18/2003 2:47:42 AM
Hi all,

Can anyone tell me which .NET class I need (or provide a code sample) to
download file from a website/url (Not FTP) and save it to my hard drive.

Kind regards,



Chris

Cor
12/18/2003 9:17:59 AM
Hi Chris,

system.net.Webclient

Cor
[quoted text, click to view]

Vijayakrishna Pondala
12/31/2003 11:35:53 AM
use the following code:

url - the url of the file to be downloaded.
// Create a request to the URL.

WebRequest request = WebRequest.Create(url);

// Get response from the request made, as a stream

WebResponse response = request.GetResponse();

Stream stream = response.GetResponseStream();

StreamReader reader = new StreamReader(stream);

// read the content of the stream as a string.

string content = reader.ReadToEnd();

// save the same in a temp file.

"Chris Morrison"
<chris-[NO-SPAM]morrison@rassalom-[SPAM_BLOCK]technology.co.uk> wrote in
message news:eoUuXCRxDHA.2652@TK2MSFTNGP09.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button