问题
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) withImage 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