不能使用以下方法调用图片
//1 Image img = Image.FromFile(path); //2 pictureBox1.Image = Image.FromFile(path); //
解决方法:
应该使用如下函数将图片转换成数据流形式,再调用
public Image GetImage(string path) { FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); Image result = Image.FromStream(fs); fs.Close(); return result; }
//1 Image img = GetImage(path); //2 pictureBox1.Image = GetImage(path);