Is the image loaded from url in winforms picturebox stored in cache?

烈酒焚心 提交于 2020-01-06 19:46:08

问题


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?


回答1:


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

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




回答2:


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



来源:https://stackoverflow.com/questions/14072133/is-the-image-loaded-from-url-in-winforms-picturebox-stored-in-cache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!