How to download an image from the internet with C #?

7

For example, I need to download a sequence of images:

http://www.simepar.br/site/fragmentos/radar/simepar_24.gif
http://www.simepar.br/site/fragmentos/radar/simepar_23.gif
http://www.simepar.br/site/fragmentos/radar/simepar_22.gif

How would you do it in C #? You would have to view this image in a PictureBox a>?

    
asked by anonymous 05.03.2014 / 18:29

3 answers

3

You can use WebClient to do this:

WebClient client = new WebClient();
Stream stream = client.OpenRead(imageUrl);

Take a look at this article that best explains link

Embrace

    
05.03.2014 / 19:17
3

I think the way below scrolls, and easier

for (int i = 10; i <= 30; i++)
{
    string nomeArquivo = @"c:\download\arquivo_" + i + ".jpg";
    using(WebClient cliente = new WebClient())
    {
        cliente.DownloadFile("http://www.simepar.br/site/fragmentos/radar/simepar_" + i + ".gif", nomeArquivo);
    }

}

Try a few variations to better suit what you want.

    
06.03.2014 / 12:41
1

If you are talking about Windows Forms, you can use the Load method of PictireBox by passing a URL:

pictureBox1.Load("http://www.simepar.br/site/fragmentos/radar/simepar_24.gif");
    
05.03.2014 / 18:55