So I just started learning C# last night. The first project I started was a simple Image-Downloader, which downloads all images of a website using HtmlElementCollection.
Here's what I got so far:
private void dl_Click(object sender, EventArgs e)
{
System.Net.WebClient wClient = new System.Net.WebClient();
HtmlElementCollection hecImages = Browser.Document.GetElementsByTagName("img");
for (int i = 0; i < hecImages.Count - 1; i++)
{
char[] ftype = new char[4];
string gtype;
try
{
//filetype
hecImages[i].GetAttribute("src").CopyTo(hecImages[i].GetAttribute("src").Length -4,ftype,0,4) ;
gtype = new string(ftype);
//copy image to local path
wClient.DownloadFile(hecImages[i].GetAttribute("src"), absPath + i.ToString() + gtype);
}
catch (System.Net.WebException)
{
expand_Exception_Log();
System.Threading.Thread.Sleep(50);
}
Basically it's rendering the page in advance and looking for the images. This works pretty well, but for some reason it only downloads the Thumbnails, but not the full (high-res) image.
Additional Sources:
Documentation on WebClient.DownloadFile: http://msdn.microsoft.com/en-us/library/ez801hhe(v=vs.110).aspx
The DownloadFile method downloads to a local file data from the URI specified by in the address parameter.