0

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?

4 Answers 4

2

You can use Application.ExecutablePath property

Gets the path for the executable file that started the application, including the executable name.

1
  • thank you for answer my question. 'Application.ExecutablePath' shows executable file location.I want windows program file location. Commented Jun 24, 2013 at 11:14
1

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

1

You can use Assembly.GetExecutingAssembly():

var location = System.Reflection.Assembly.GetExecutingAssembly().Location;
1

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,

Not the answer you're looking for? Browse other questions tagged or ask your own question.