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?

r.vengadesh
  • 1,721
  • 3
  • 20
  • 36

4 Answers4

2

You can use Application.ExecutablePath property

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

Tigran
  • 61,654
  • 8
  • 86
  • 123
  • thank you for answer my question. 'Application.ExecutablePath' shows executable file location.I want windows program file location. – r.vengadesh Jun 24 '13 at 11:14
1

You can use Assembly.GetExecutingAssembly():

var location = System.Reflection.Assembly.GetExecutingAssembly().Location;
Darren
  • 68,902
  • 24
  • 138
  • 144
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

Community
  • 1
  • 1
Mogli
  • 1,972
  • 11
  • 34
  • 67
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,

Kas
  • 3,747
  • 5
  • 29
  • 56