Post: Image Downloader [source]
05-20-2012, 06:16 AM #1
Pichu
RIP PICHU.
(adsbygoogle = window.adsbygoogle || []).push({}); I'm going to say this, this is the source to what I have compiled together pretty quickly. It's a bugged source so I wouldn't Copy/Paste it and try and use it.

Just good for showing how I kinda did it as well as a place to store for me to look at later on, if I need to.

I do plan on cleaning the code way up as it is messy as f*ck and the UI is crap...

It does however work but it seems to skip the 1st image and occasionally skip 3 of the last images. Going to figure this out tomorrow by re-writing it all.

Reason for this is that I needed something to be able to download over 2,000 different images/gifs of Pokemon. I have downloaded over 900 of them so far in under 5 minutes with the program. It's initially meant for that but I plan on adding to it so I can download off of DamnLOL or LolBird or anything else that uses number/string intervals.

Yea, I know there is HTTPRequest, I gave it a try but still don't 100% understand it yet so. :/

Here is the source

    

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;


namespace Image_Downloader
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}


string path = "";
int min;
int max;
string imagetype;
int Success = 0;
int Error = 0;
List<string> wl = new List<string>();


private void Form1_Load(object sender, EventArgs e)
{


}


private void button1_Click(object sender, EventArgs e)
{
imagetype = textBox2.Text;
textBox3.Text = textBox1.Text + numericUpDown1.Value.ToString() + imagetype;
CheckButtons();
textBox3.BackColor = Color.Lime;
textBox3.ForeColor = Color.Red;
min = Convert.ToInt32(numericUpDown1.Value);
max = Convert.ToInt32(numericUpDown2.Value);
DevelopingLinks();
}


private void button2_Click(object sender, EventArgs e)
{
FolderBrowserDialog fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == DialogResult.OK)
{
path = fbd.SelectedPath + "\\";
textBox4.Text = path;
CheckButtons();
}
}


private void button3_Click(object sender, EventArgs e)
{
if (button3.Text == "Start")
{
int totalimages = Convert.ToInt32(numericUpDown2.Value - numericUpDown1.Value) + 1;
DialogResult message = MessageBox.Show("Total Images To Be Downloaded = " + totalimages + "\nSave To: " + path, "Checking", MessageBoxButtons.YesNo);
if (message == DialogResult.Yes)
{
button3.Text = "Stop";
disabler();
Downloader();
}
}
else
{
button3.Text = "Start";
enabler();
}
}
public void CheckButtons()
{
if (textBox3.Text.Length > 7 && textBox4.Text.Length > 3)
{
button3.Enabled = true;
}
}
public void DevelopingLinks()
{
if (richTextBox1.Text == "")
{
richTextBox1.Clear();
for (int a = Convert.ToInt32(min); a <= Convert.ToInt32(max); a++)
{
string weblink = textBox1.Text + a + imagetype;
wl.Add(weblink);
richTextBox1.Text += "Adding Link: " + weblink + "\nTotal Links: " + a + "\n";
if (a >= max + min + 1)
{
MessageBox.Show("Completed");
}
}
}
else
{
DialogResult clearit = MessageBox.Show("Clear Current Links For New Ones?", "Clear?", MessageBoxButtons.YesNo);
if (clearit == DialogResult.Yes)
{
richTextBox1.Clear();
for (int a = Convert.ToInt32(min); a <= Convert.ToInt32(max); a++)
{
string weblink = textBox1.Text + a + imagetype;
wl.Add(weblink);
richTextBox1.Text += "Adding Link: " + weblink + "\nTotal Links: " + a + "\n";
if (a >= max + min + 1)
{
MessageBox.Show("Completed");
}
}
}
}
}
public void Downloader()
{
int newsetvalue = Convert.ToInt32(numericUpDown1.Value);
for (int a = newsetvalue; a < max; a++)
{
try
{
string uri = wl[newsetvalue];
WebClient wc = new WebClient();
Stream img = wc.OpenRead(uri);
Bitmap bp = new Bitmap(img);
if (bp != null)
{
bp.Save(path + newsetvalue + textBox2.Text);
Success++;
richTextBox1.Text += "Successfull Image: " + path + a + textBox2.Text + "\n";
newsetvalue++;
label4.Text = "Successful Images: " + Success + " Failed Images: " + Error;
}
else
{
a++;
Error++;
label4.Text = "Successful Images: " + Success + " Failed Images: " + Error;
}
if (a == max)
{
MessageBox.Show("Completed!");
button3.Text = "Start";
richTextBox1.Text += "Failed Image: " + path + newsetvalue + textBox2.Text + "\n";
}
img.Flush();
img.Close();
wc.Dispose();

}
catch
{

}
}
}
public void disabler()
{
textBox1.ReadOnly = true;
textBox2.ReadOnly = true;
numericUpDown1.Enabled = false;
numericUpDown2.Enabled = false;
button1.Enabled = false;
button2.Enabled = false;
minmaxcheck.Stop();
}
public void enabler()
{
textBox1.ReadOnly = false;
textBox2.ReadOnly = false;
numericUpDown1.Enabled = true;
numericUpDown2.Enabled = true;
button1.Enabled = true;
button2.Enabled = true;
minmaxcheck.Start();
}
private void minmaxcheck_Tick(object sender, EventArgs e)
{
if (numericUpDown1.Value >= numericUpDown2.Value)
{
numericUpDown1.Value = numericUpDown2.Value - 1;
}
}
}
}





You must login or register to view this content.You must login or register to view this content.
(adsbygoogle = window.adsbygoogle || []).push({});

The following user thanked Pichu for this useful post:

One

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo