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

Asked

Viewed 1,552 times

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 I do that in C#? Would I have to display that image in a Picturebox?

  • 1

    Is it windows-Forms? or web-Forms? What is the technology you are using?

  • @Miguelangelo the tag on the question makes it clear that it is winforms

3 answers

3

I think the way down rolls, 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 some variations to get better adapted to what you want.

3

1

If you’re talking about Windows Forms, then you can use the method Load of Pictirebox passing a URL:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.