关闭Image.FromFile(filePath)打开的文件

两种方法,思路一样的,做哥拷贝。。不懂为什么FromFile函数自己没做。

1 string filenameOf = @ "D:\images\dao.gif ";
2 FileStream fs = new FileStream(filenameOf,FileMode.Open, FileAccess.Read);
3  int byteLength = (int)fs.Length;
4  byte[] wf = new byte[byteLength];
5 fs.Read(wf,0,byteLength);
6 fs.Close();


1 Image img = Image.FromStream(new MemoryStream(wf));
2 this.pictureBox1.Image = img;
3
4 Image image = Image.FromFile(obj.FileName);
5 Image bmp = new Bitmap(image);
6 image.Dispose(); //这句话很重要
7 pictureBox1.Image = bmp;

posted on 2011-04-04 00:09  小交响曲  阅读(1294)  评论(0编辑  收藏  举报

导航