我想在picturebox中浏览图片文件,但是浏览后的文件将无法被其它程序编辑。
好像用如下方法释放资源也不行!
Bitmap b=new Bitmap(".\\temp.jpg");
pictureBox1.Image=b;
b.Dispose();
在Main()函数中提示错误“使用了无效参数” 
请问如何解决呀?

解决方案 »

  1.   

    非当前浏览的没问题:
    picturebox1.image=image.fromfile(filename)
    picturebox1.image.dispose()如果要编辑当前看到的,可以先复制为一个临时文件进行编辑
      

  2.   

    但是picturebox1.image=image.fromfile(filename)中的filename无法被替换呀!
    如果我想编辑完后,如何把编辑完的文件显示呢?
      

  3.   

    GC.Collect();要释放资源加上上面一句,很有效。
      

  4.   

    调用时 :
    PictureBox.Image=Image.FromFile(strFileName)需要释放时:
    PictureBox.Image.Dispose();
    PictureBox.Image=null;即可