Setting Application path and sub folders correctly

Posted on 2007-09-28
Last Modified: 2008-01-09
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...
Question by:bearpaws
    LVL 27

    Assisted Solution

    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.

    LVL 27

    Expert Comment

    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 =


    Author Comment

    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.
    LVL 27

    Expert Comment

    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.


    Author Comment

    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.
    LVL 27

    Expert Comment

    If you type "My."  does "Resources" come up ion intellisense?

    For example:


    Author Comment

    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")
    LVL 85

    Accepted Solution

    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

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now