Jump to content

Here 's another class that I think you might find useful Padre 's downloader class is ok, but...


G+_Joe Maruschek
 Share

Recommended Posts

Here's another class that I think you might find useful.  Padre's downloader class is ok, but I wanted something that would let me download a web site right into a string.  The WebClient class in the .NET FCL is pretty easy to use, and it has a bunch of methods for downloading and uploading stuff to the web. 

 

I made a small example program that downloads the current Astronomy Picture of the Day web page into a string.  Then I used the Regex class to find the image tag in it, and then I download the image file.  If you run the code on your computer, be sure to change the location where the file gets saved, or the WebClient class will throw an exception that it couldn't download the file.

 

You can read more about all the methods and properties of the WebClient class here: http://msdn.microsoft.com/en-us/library/system.net.webclient%28v=vs.110%29.aspx

https://github.com/joemarus/csharp_part2_examples/blob/master/WebClientExample.cs

Link to comment
Share on other sites

 Share

×
×
  • Create New...