Click to See Complete Forum and Search --> : [RESOLVED] FileNotFoundException


funnyusername
January 28th, 2009, 03:43 PM
Does this code look ok to you?

pictureBox1.Image = System.Drawing.Image.FromFile("..\\MyNewProject\\Resources\\Adhesive.jpg");

Here is the file path from Windows:

C:\Documents and Settings\D. Murphy\My Documents\Visual Studio 2008\Projects\Project1\MyNewProject\MyNewProject\Resources\Adhesive.jpg

I've tried about twenty variations of the file path in my command so far and can't seem to get it....

The Project Solution file is in:

C:\Documents and Settings\D. Murphy\My Documents\Visual Studio 2008\Projects\Project1\MyNewProject

dannystommen
January 28th, 2009, 04:18 PM
if the file is included in the resource, you can retrieve it like

pictureBox1.Image = Properties.Resources.Adhesive;

JonnyPoet
January 28th, 2009, 06:13 PM
if the file is included in the resource, you can retrieve it like

pictureBox1.Image = Properties.Resources.Adhesive;

But you cannot only using windows to copy it into the resources file, you need to add it to the resources using Visual Studio before you can use it.

funnyusername
January 28th, 2009, 06:41 PM
Thankyou both very much. I had been trying it using the resource first, and couldn't get it working from code, so I switched to trying to reference the file directly. Its working now. :)

funnyusername
January 28th, 2009, 06:56 PM
Johnny, thanks for your articles by the way, the dockable panels one is excellent.