Loading PictureBox Image from resource file with path (Part 3)

zetar picture zetar · Jun 19, 2013 · Viewed 184.6k times · Source

I understand that this question has been asked (and answered) before. However, none of the solutions are working for me.

Below is a screen capture of all the relevant pieces of the puzzle:

Screen capture http://dinosaur-island.com/PlantPictureBoxScreenCap.jpg

As you can see there are numerous bitmaps of plants loaded as resources into the Images folder. There is a form with a picturebox named "PlantPicture". There is string, which I know has a good path (because I've checked it in the debugger):

            PicPath = PicPath+".bmp";

Screen capture http://dinosaur-island.com/PlantDebugger.jpg

I've tried numerous ways of loading, casting, etc., etc.

Answer

ispiro picture ispiro · Jun 19, 2013

The path should be something like: "Images\a.bmp". (Note the lack of a leading slash, and the slashes being back slashes.)

And then:

pictureBox1.Image = Image.FromFile(@"Images\a.bmp");

I just tried it to make sure, and it works. This is besides the other answer that you got - to "copy always".