Todd Vance

Todd Vance

  • NA
  • 60
  • 131.6k

The path for images in a resource folder in project

May 29 2007 11:14 PM


I am trying to make an app with several random cards drawn on it -- I have added a folder named "resources" to the project and added a few playing card images to it (1.jpg, 2.jpg, etc.).

To fill the picturebox that I have I just made a bitmap including the FULL path --- this is not what I want because this obviously will not be the right path for everyone who downloads and looks at my application.

What path would I use for an image in a folder that has been added to the project???

Below is my clunky code -- any advice would be helpful.  I am eventually going to have 21 pic boxes that will be filled by 21 random cards.  But for right now I am just trying to figure out the easiest and cleanest way to fill 1 picbox.

private void button1_Click(object sender, EventArgs e)

{

deck myDeck = new deck(2);

Bitmap card1 = new Bitmap("C:\\Documents and Settings\\**\\My Documents\\Visual Studio 2005\\Projects\\theDeck\\theDeck\\resources\\" + myDeck.cards[0].ToString() + ".jpg");

pile1image1.Image = card1;

}


Answers (4)