Created
March 4, 2012 17:34
-
-
Save jamesmanning/1974025 to your computer and use it in GitHub Desktop.
download urls, non-async, takes one string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net; | |
namespace ItsBigItsHeavyItsWood | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
var urlsToDownload = new[] | |
{ | |
"http://www.google.com/", | |
"http://www.microsoft.com/", | |
"http://www.apple.com/", | |
}; | |
foreach (var url in urlsToDownload) | |
{ | |
DownloadUrl(url); | |
} | |
Console.ReadLine(); | |
} | |
private static void DownloadUrl(string url) | |
{ | |
var client = new WebClient(); | |
Console.WriteLine("Starting to download url {0}", url); | |
var contents = client.DownloadData(url); | |
Console.WriteLine("Downloaded {0} bytes", contents.Length); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment