Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of Application.ExecutablePath in Windows Service

In a windows forms application, I use Application.Executable path to get to the App.config.,

I need to get to app.config in Windows Service.. What would that be ?

like image 815
TonyP Avatar asked Jun 19 '13 12:06

TonyP


1 Answers

A couple of options:

System.Reflection.Assembly.GetExecutingAssembly().Location

For the current assembly. or, you can derive it from a type:

System.Reflection.Assembly.GetAssembly(typeof(MyAssemblyType)).Location

Then (on either) you can use Path.GetDirectoryName to get the folder it's originating from (assuming your app.config is within that same directory).

like image 107
Brad Christie Avatar answered Oct 03 '22 16:10

Brad Christie