Is the image loaded from url in winforms picturebo

2019-09-07 08:55发布

In a form in winform application i have to show images (multiple images) stored on webserver. There is no problem in showing images as i can simple assign URL to picturebox.

picturebox1.ImageLocation = "http://example.com/Image.jpg";

That form will be opened many times frequently, right now each time form is opened, images are being downloaded every time. It is unnecessary increasing traffic.

Is it possible to tell picturebox to cache image (as Browser do), so next time same images is requested, it should load quickly. Is that possible?

2条回答
Summer. ? 凉城
2楼-- · 2019-09-07 09:05

Pre-load the image(s) with
Image img = Image.FromFile("...");

Then you can give the image to the PictureBox:
pictureBox1.Image = img;

查看更多
Melony?
3楼-- · 2019-09-07 09:09

You can store the image in a temp folder and check the temp the folder first when opening the form.

查看更多
登录 后发表回答