How to refer a file under its project folder

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

Hi, I have a question as below:
* myProject\bin\debug\question.bmp // image file
* new Bitmap(@"question.bmp"); // use it
* If I still want use line 2 to use it,
but I want to store the file directly under myProject
Please advise.
Peter
 
* new Bitmap(@"..\..\question.bmp"); // use it

"..\" will bring you to the parent directory, you can repeat this as many
times as is needed: "..\..\".
 
Thanks Jan. Your way is a solution. Later I found another
solution like below:
* add the file in the project
* in its properties window of the file,
set property Build Action to embedded resource
* The exe file size increases. This way is less dynamic.
Thanks again.
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top