In my c# windows project i create a installer file.I add some image into program file folder. So i want to locate program file folder and get the image.
Anybody know how to locate that?
In my c# windows project i create a installer file.I add some image into program file folder. So i want to locate program file folder and get the image.
Anybody know how to locate that?
You can use Application.ExecutablePath
property
Gets the path for the executable file that started the application, including the executable name.
You can use Assembly.GetExecutingAssembly()
:
var location = System.Reflection.Assembly.GetExecutingAssembly().Location;
i do this like, just make a folder call it Resources and add the image files in it and retrieve it like this and finally add the Resources folder while making setup. I found this easy.
Image imageNormal = Image.FromFile("Resources\\button_Image.png");
controlName.Image = imageNormal;
In case if you are looking for this
C# - How to get Program Files (x86) on Windows 64 bit and
How do get the path of Program Files regardless of the architecture of the target machine
It's very Easy , Try the following code AppDomain.CurrentDomain .BaseDirectory
You can try this code to get iamges
Image.FormFile("Imagename.jpeg" )
this code itself located the application direcotry for example if you write
Image.FromFile("Imagename.jpeg")
then it will retrive images in bin folder,