C# 用FiLestream读取图片的问题

来源:百度知道 编辑:UC知道 时间:2024/06/08 11:49:03
我想从文件读取图片,但是不影响对其文件的操作。用filestream,为什么有时候会出现内存不足的问题
System.IO.FileStream fs = new System.IO.FileStream(of.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
pictureBox1.Image = Image.FromStream(fs);
fs.Dispose();

fs.Dispose()这句话不能在设置了pictureBox1.Image=Image.FromStream(fs)之后立即执行

建议使用Image.FromFile

图片要的好像是Stream类型的 难道是我记错了?