C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,112 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I have a new WinForms project:
I want to load an image from a URL. When I run the app, nothing shows up. I've tried the following:
pic1.LoadAsync(url);
pic1.ImageLocation = url;
Both of these just result in a placeholder image coming back.
I've also tried downloading the stream - but it is getting stuck
using (WebClient webClient = new WebClient())
{
byte[] data = webClient.DownloadData(url);
using (MemoryStream mem = new MemoryStream(data))
{
using (var yourImage = Image.FromStream(mem))
{
}
}
}
Any ideas how to solve for this?
What is the URL ?
If I test with one of my test images, in the constructor, with a PictureBox pictureBox1:
public Form1()
{
InitializeComponent();
pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
pictureBox1.ImageLocation = "https://i.ibb.co/DG7XSsB/Butterfly.png";
}
I get the image :