|
-
January 28th, 2009, 04:43 PM
#1
[RESOLVED] FileNotFoundException
Does this code look ok to you?
Code:
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
Last edited by funnyusername; January 28th, 2009 at 04:46 PM.
-
January 28th, 2009, 05:18 PM
#2
Re: FileNotFoundException
if the file is included in the resource, you can retrieve it like
Code:
pictureBox1.Image = Properties.Resources.Adhesive;
-
January 28th, 2009, 07:13 PM
#3
Re: FileNotFoundException
 Originally Posted by dannystommen
if the file is included in the resource, you can retrieve it like
Code:
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.
 Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
-
January 28th, 2009, 07:41 PM
#4
Re: FileNotFoundException
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.
Last edited by funnyusername; January 28th, 2009 at 07:56 PM.
-
January 28th, 2009, 07:56 PM
#5
Re: [RESOLVED] FileNotFoundException
Johnny, thanks for your articles by the way, the dockable panels one is excellent.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|