C#winform program, let PictureBox display images (including GIF), and is not occupied, can instantly delete pictures.

Source: Internet
Author: User

Recently in doing a picture browsing tool, you need to display image files in PictureBox, including GIF playback. and cannot be exclusive to the program, even if the WinForm program is displaying this graph, it can also delete it in the explorer.

Look at the example on the Internet, light a GIF picture, someone is saying to use a label instead of PictureBox, and then set as a background image, someone said to use GDI + to achieve, some people say creategraphics. In fact, I also preview the film, which has so much trouble. Just the following lines of code are sufficient.

The code is as follows:

     Public void ShowImage (string  path)   {

if ((this.pictureBox1.Image! = null))//release First
{
PictureBox1.Image.Dispose ();
pictureBox1.Image = null;
}

            = Image.FromFile (path);   // Loading Pictures            New // Create a new MemoryStream            Img. Save (MSTR, imageformat.gif);        // Save this object            // Show            Img. Dispose (); // release occupancy
File.delete (path); }

Don't climb walls with google:www.gaomn.com.

Heat Map Bar: www.retu8.com

8KMM Gallery: www.8kmm.com

C#winform program, let PictureBox display image (including GIF), and is not occupied, can instantly delete pictures.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.