【问题标题】:Can't find path to Image in pictureBox,Image = new Bitmap(path)在pictureBox中找不到Image的路径,Image = new Bitmap(path)
【发布时间】:2012-05-24 20:02:43
【问题描述】:

我需要将图片加载到 WindowsCE 6.0 中的图片框。当我在手机中运行程序时,它告诉我它找不到路径。 这是我的代码:

this.pictureBox1.Image = new Bitmap(@" Data Source = \Program Files\Data\Image20120523_1.jpeg ");

我已经尝试过使用此路径,但它不起作用:

路径1:@"\Program Files\Data\Image20120523_1.jpeg"
路径2:“\Program Files\Data\Image20120523_1.jpeg”

我有一个位于同一路径的数据库,当我使用它建立连接时它工作正常,为什么它无法加载图像?

解决方案 这条路径可以正常工作:

this.pictureBox1.Image = new Bitmap(@"\Program Files\Data\Image20120523_1.jpeg");

感谢您的帮助!

【问题讨论】:

  • 好吧,你绝对不应该在引号中包含 'Data Source ='。

标签: c# winforms image picturebox


【解决方案1】:

您需要在此处使用图像文件的简单路径。像这样:

this.pictureBox1.Image = new Bitmap(@"E:\temp\photo\IMG_1461.JPG");

【讨论】:

  • 我已经尝试过使用该路径,但它不起作用。我在这个路径中有我的图片:Program Files\Data\Myphoto.jpg,因为它在移动设备中我不能像“E:”这样的路径。我发现我必须放类似 Data Source = path 的东西。还有什么想法吗?谢谢!
猜你喜欢
  • 2011-12-24
  • 1970-01-01
  • 1970-01-01
  • 2016-07-29
  • 1970-01-01
  • 2019-06-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多