【发布时间】:2014-03-29 05:05:18
【问题描述】:
我正在使用 Winforms 并且有一个图片框。当用户单击它时,我想从我的计算机加载图像。但它不起作用。任何想法为什么?
private void pictureBox1_Click(object sender, EventArgs e)
{
pictureBox1.Image = Image.FromFile("C:/wamp/www/cyber.jpeg");
pictureBox1.Image = new Bitmap(@"C:\wamp\www\cyber.jpeg");
}
如果我单击它,我会收到错误“FileNotFoundException was unhandled”。如果我删除 Image.FromFile 并改用位图,则会收到错误“参数无效”
【问题讨论】:
-
你有没有文件扩展名
.jpeg或.jpg检查。 -
那么,很明显,您的文件名和/或文件路径是错误的!
-
我已经编辑了你的标题。请参阅“Should questions include “tags” in their titles?”,其中的共识是“不,他们不应该”。