CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2008
    Posts
    169

    [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.

  2. #2
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: FileNotFoundException

    if the file is included in the resource, you can retrieve it like
    Code:
    pictureBox1.Image = Properties.Resources.Adhesive;

  3. #3
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: FileNotFoundException

    Quote Originally Posted by dannystommen View Post
    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

  4. #4
    Join Date
    Jul 2008
    Posts
    169

    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.

  5. #5
    Join Date
    Jul 2008
    Posts
    169

    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
  •  





Click Here to Expand Forum to Full Width

Featured