Defining relative paths to files for a project...

perps

Member
Joined
Sep 8, 2005
Messages
14
Programming Experience
Beginner
Greetings all,

I'm currently working on a project where i have created some custom images for use as buttons.

I have created one button to serve to indicate that a button is unselected, and another image of a different colour to be used when the user clicks the button to indicate that it is selected. I know how to switch between the images, but the only way i can do it at the moment is to specify the full path to the image i want to change to. This works fine for the moment, but i want to be able to export the project/set it up on other computers etc, so is there a way to setup relative paths to accomplish this??? I have created a 'Buttons' directory inside my project folder, is there some way in which i can point to the image i wish to change to using a relative path, e.g. "/buttons/lineSelected.jpg"???

Any help muchly appreciated,

- perps.
 
Last edited:
You have several choices. If you aren't going to want to be able to change the images you use for the buttons once the app is deployed then your images should be embedded resources rather than stand-alone files. You could add an image list to a form and then add the images to it. Otherwise, you could add your image files to your project in the solution explorer and change their build action to Embedded Resource. If you do want to use stand-alone files, you can create any path in code relative to your program directory using Application.StartupPath.
 
Back
Top