Using the resource folder

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kronecker@yahoo.co.uk

    Using the resource folder

    I have an image which I need to load

    PictureBox1.Ima ge = Image.FromFile( My.Resources.my image)

    and this worked fine when the image (myimage.jpg) was in the debug Bin
    directory. I now am moving them all to
    a folder called Resources and specify the files as above. Doesn't work
    though and the file is definitely there and VB.Net recognizes it when
    I type in the expression. What's wrong? it's looking for a string.


    Thanks

    K.
  • kimiraikkonen

    #2
    Re: Using the resource folder

    On Jul 17, 2:09 am, kronec...@yahoo .co.uk wrote:
    I have an image which I need to load
    >
    PictureBox1.Ima ge = Image.FromFile( My.Resources.my image)
    >
    and this worked fine when the image (myimage.jpg) was in the debug Bin
    directory. I now am moving them all to
    a folder called Resources and specify the files as above. Doesn't work
    though and the file is definitely there and VB.Net recognizes it when
    I type in the expression. What's wrong? it's looking for a string.
    >
    Thanks
    >
    K.
    Hi,
    Maybe you linked the image instead of embedding, see your
    application's Properties -Resources, then click on your image, then
    check the option called "persistenc e", maybe you can change it
    "embedded in .resx" if it was set to "linked at compile time" by
    default.

    And maybe that may be helpful:


    Hope this helps,

    Onur Güzel

    Comment

    • Patrice

      #3
      Re: Using the resource folder

      Please never post about an error without telling us the error message.

      Image.FromFile loads a file from a file name so my guess is that you perhaps
      thought you used image file resources (?) when your resources are actually
      just the file names.

      It worked as long as the exe file and the image files were in the same
      directory but stopped working then...

      You could :
      - either keep this and specify the directory from which image files should
      be loaded
      - truly add images as resources in which case you'll have just to do
      PictureBox1.Ima ge=My.Resources .ResourceFile.M yImage...

      --
      Patrice

      <kronecker@yaho o.co.uka écrit dans le message de groupe de discussion :
      e5ac909b-fe0e-4cd1-8f35-d043a135df3b...le groups.com...
      I have an image which I need to load
      >
      PictureBox1.Ima ge = Image.FromFile( My.Resources.my image)
      >
      and this worked fine when the image (myimage.jpg) was in the debug Bin
      directory. I now am moving them all to
      a folder called Resources and specify the files as above. Doesn't work
      though and the file is definitely there and VB.Net recognizes it when
      I type in the expression. What's wrong? it's looking for a string.
      >
      >
      Thanks
      >
      K.

      Comment

      Working...