PictureBox.Image = Image.Fromfile("D:/1.jpg");
pictureBox要一直显示的,接下来1.jpg被修改时资源被占用。请问如何在pictureBox显示图片后释放其对图片资源的占用,以便其他程序能访问该图片资源。

解决方案 »

  1.   

    你可以这样,有2种解决方法
    1,
    PictureBox.Image = Image.Fromfile("D:/1.jpg");
    Picturebox1.Image.Dispose()
    方法2
    System.IO.FileStream fs = null;
    fs = new System.IO.FileStream("D:/1.jpg", System.IO.FileMode.Open, System.IO.FileAccess.Read);
    PictureBox1.Image = System.Drawing.Image.FromStream(fs);
    fs.Close();
      

  2.   

    http://hi.baidu.com/jiang_yy_jiang/blog/item/266ae4dd55d544cf8d102992.html
      

  3.   

    感谢回复,已经解决
    但是使用孟子说的第一张说法,调用dispose之后图片显示也没有了,最后使用了FileStream