I am trying to get the path of an image file which I added in solution explorer in Visual Studio, but I couldn't get the relative path of that image. H is the file structure of my project:
With all respect to given other answers, I come up with my own answer after a year, seems like a progress :)
When it is the case that you want to use any kind of external file, it is certainly a way to put them in a folder within your project, but not as valid as getting them from resources. In a regular visual studio project, you should have a
Resources.resx file under
Properties section, if not you can easily add your own Resource.resx file. And add any kind of file in it, you can reach the walkthrough for adding resource files to your project here.
And after having resource files in your project calling them is easy as this:
var myIcon = Resources.MyIconFile;
And of course you should add the using statement of
Properties of your project like this:
I hope this will help someone.