Search code examples
c#graphicsiosystem

How to constantly get same directory path from inner directory


I am using c#.

I have a project running at path: D:\USER\Desktop\Prgramming\C++ 2020-2021\project\projectGraphics\projectGraphics\bin\Debug The Project directory looks like this: Project directory

I want to get constantly (in any computer) from an .exe file in Debug to an image in Resources efficiently. How can I do that?


Solution

  • Do you use WinForms or WPF?

    Add the image as a "resource" in your project. Add Image to ResourceFile Afterwards you can use

    Bitmap bmp = new Bitmap(Properties.Resources.myImageFile);
    

    to access the image.