tags:

views:

257

answers:

3

I am trying to download image from HTTP URL to my computer via c#. Example picture: http://www.hcs.harvard.edu/csharp/Logo1.png

I am using cURL to fletch it. Then I am saving it to computer as picture.jpg, but the file is corrupted. It is not recognized as picture

What is the correct way of doing this ?

Thanks

+4  A: 

I don't completely understand the question, but my first thought is that saving a .png as .jpeg would be a good place to start investigating.

Ian P
Already did that - The same happened - I have used PHP to do the same thing but PHP saves the image the right way.
raimis
+1  A: 

Have you tried saving it as picture.png?

gkrogers
+5  A: 

Why not use System.Net.WebClient for this?

WebClient client = new WebClient();
client.DownloadFile("http://www.hcs.harvard.edu/csharp/Logo1.png", "Logo1.png");
TomWij
This will do the work, Thanks!
raimis
I don't get it -- how did this answer the question? That's not a JPEG file.
John Feminella
I think the title is misleading - he was actually trying to download a png over http, given a URL to it, not convert it.
gkrogers
It's indeed a bit confusing so I based myself on the context. I don't know about cURL, that might have just worked. Just wanted to show him a more common way to do it... :-)
TomWij