Reputation: 11
I'm trying to load several images from URLs to a pictureBox. My problem is that "pictureBox.Load(URL)" or "pictureBox.ImageLocation = URL" doesn't work. I don't know why, I think it is because the URL doesn't have an extension like .jpg.
private void button3_Click(object sender, EventArgs e)
{
string URL = "https://internetmarke.deutschepost.de/internetmarke/franking/image/view/1403556118.do";
pictureBox1.ImageLocation = URL;
}
The URL works in Firefox and the picture is shown. But in IE it doesn't work and I think that's the same reason why it's not working in .NET.
IE says "unknown filetype" and wants to download a "1403556118.do" file.
In C# I only get a red X in the pictureBox.
When I first try to load it in IE, it works in the pictureBox (IE cache?)
Does somebody knows another possibility to load this images to a pictureBox?
EDITED: Added sample code.
Today I've tested the code on three different computers and with different Internet connections; Home DSL, Company DSL and a UMTS/3G Surf-Stick. All without any proxies and also tested without virusscan.
In every single scenario it didn't work, same as I wrote in my first post.
After I accessed some of the URLs in Firefox or IE, the images of these URLs showed up in my application. All others remained a red X.
Is there any different (old-school^^) method to load these images, like downloading the HTTP-Stream into a byte array and then copy this into pictureBox.Image or something?
Dino
Upvotes: 0
Views: 15155
Reputation: 1
This should work since you're loading an image from a remote URL:
pictureBox1.Load(URL);
Upvotes: 0
Reputation: 11
@Andrew:
pictureBox1.ImageLocation = "http://www.micoequipment.com/products/large/MF_260_l.jpg";
This Works!
pictureBox1.ImageLocation = "https://internetmarke.deutschepost.de/internetmarke/franking/image/view/1403556118.do";
This doesn't work!
Your link and my link both work in Firefox. But my link doesn't work in IE and it doesn't work in .NET and in the pictureBox.
Upvotes: 0
Reputation: 7788
pictureBox1.ImageLocation = "http://www.micoequipment.com/products/large/MF_260_l.jpg"; //should work
Make sure that image is accessible via web browser (test it before). Also, please make sure that you are calling correct picture box :) It works for me.
Upvotes: 2