• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

Setting Application path and sub folders correctly

Hi folks,

    I have a question here concerning an application that I have written. I am rather confused about when I create my executable file and the pathing to sub folders. I have several folder such as images and etc. that I reference in my coding. Example  somehting = "images/work.gif"
My question is that I do not think I am referencing them correctly for when I create a package to install
this application on another computer. I am a tad bit confused by it all.
Any help appericated...
  • 4
  • 3
2 Solutions
Add your image to your project Resources, and then access it like that.  For example:

To add an image as a resource:
    Project Menu | Properties
    Click on the Resources Tab
    Click on the down arrow to the right of the Add Resource button
    Select Add Existing File...  and then navigate to, and select your image (example:  work.gif)
Now, instead of referencing the path to the image file, reference your image like this:

And you shouldn't have any problems when you deploy your app.

An additional example would be, if you had a PictureBox on your form and you wanted to show the
image file from your Resources:

    Me.PictureBox1.Image = My.Resources.work

bearpawsAuthor Commented:
I must be dumber than a box of rocks. I selected Project , then click on my the name of my application properties - ie Bearpaws tracking and then it brought up a box, which I selected Common propteries.
From there, I choose Add Reference path and it only allows me to add folders.
It doesn't allow me to choose individual files.
So I thought I was in the worng place and started over again, by clicking on Project and then on the option to add a reference - that does allow me to choose an individual file but errors when saving because it is not an ocx, or dll etc.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

What version of VB do you have?  I'm using VS 2005.  In VS 2005, you don't want "Add Reference", but
rather "Add Resource".

Try this approach:

    In your Solution Explorer window, find the icon at the top that says "Show All Files" when you
        hover your mouse over it, then Click it.
    Find the MyProject node, then expand it.
    Find the Resources node, then double-click it.
        You should see the Add Resources button at the top.

bearpawsAuthor Commented:
Sorry, I should have stated the version I am working in. It is Studio 2003.
It does not show a "resource" node only a "Reference" node.
If you type "My."  does "Resources" come up ion intellisense?

For example:

bearpawsAuthor Commented:
No, it doesn't, only when I type in Me. etc  
Here is how I am referencing it in my coding when the executable can not find and I do understand why
I just need to get it right when it loaded on another computer - AppPath?
    lblFood.Image = System.Drawing.Image.FromFile("images\wrong.gif")
Mike TomlinsonMiddle School Assistant TeacherCommented:
To "embed" a Resource...

Click on Project --> "Add Existing Item" and select the Image file you want to embed.
Next, in the Solution Explorer, select your newly added Image file.
Then, in the Properties Pane, change the "Build Action" from "Content" to "Embedded Resource".
The name of the embedded resource IS case sensitive.
Finally, use code like this:

    PictureBox1.Image = New Bitmap(Me.GetType, "mypicture.bmp") ' <--- change "mypicture.bmp" accordingly

This approach actually embeds the image INSIDE the exectuable file.  It can't get lost or moved by the user....  =)

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now