Bitmap.Dispose();释放后出现c# “System.ArgumentException”类型的未经处理的异常在 System.Drawing.dll 中发生

            FileStream oldpFileStream = new FileStream(leftpath, FileMode.Open, FileAccess.Read);
            Bitmap bit = new Bitmap(Image.FromStream(oldpFileStream));
            picAnalyseBefore.Image =bit;
            picAnalyseBefore.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            picAnalyseBefore.Tag = leftpath;
            oldpFileStream.Close();
            oldpFileStream.Dispose();
            bit.Dispose();
            bit = null;

 

想尽量节省资源 ,所以想每次用完Bitmap后释放,但是出现异常,,无意中把它置空后,就可以了。不明白,,,有大神说下嘛?

你可能感兴趣的:(c#,winform)