how to use an image located in a subdirectory

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I created a subdirectory in a project and added an image to the
subdirectory from the project and set its property Build Action=Embedded
Resource.
Then instanciate a image by
Image img=new Bitmap(GetType(),"HLP.BMP");

I got runtime error and it said

"System.ArgumentException: Resource 'HLP.BMP' could not be found in class
'testImage.Form1".

But If don't use subdirectory, I get no problem.

I don't see the difference to add image to subdirectory or the project
directory since set its property Build Action=Enbedded Resource. That means
the image is included in the executable.

How to fix it?

Thanks

Keith
 
You have to reference it with a dot as separator :
"SubdirA.SubdirB.FileName.bmp"

Image img=new Bitmap(GetType(),"Subdir.HLP.BMP");

Steph.
 
Back
Top