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
 
Back
Top