注册 登录
编程论坛 C# 论坛

图象显示问题

圭贵桂 发布于 2022-05-05 13:35, 1567 次点击
我用这段代码,用于显示图像,运行时出现黄色警告,不知出什么错,
  filename =  Application.StartupPath + "Gefa.png";
            PictureBox1.Image = Image.FromFile(filename);
图像放在了Resources中
  PictureBox1.Image = Image.FromFile(filename);这条黄色。
哪位指点一下。
3 回复
#2
apull2022-05-06 23:01
PictureBox1.Image = Properties.Resources.IMGNAME
IMGNAME是图片在Resources中的名字
#3
圭贵桂2022-05-12 20:05
回复 2楼 apull
谢谢二楼,
这样写是可以的,但一直搞不懂用fromFile的写法错在哪里。
而且还涉及其他要改。
网上查到的太复杂,也不理解,是不是图像存错地方了。
#4
apull2022-05-12 22:38
文件路径不对。
filename =  Application.StartupPath + "\\Gefa.png";
1