Home > database >  Find the path of the folder containing the executable of a service
Find the path of the folder containing the executable of a service

Time:08-25

I'm having some issues with a library that cannot find the path of its config file. The reason beeing that my program is deployed in a directory and installed as a service using sc.exe. When trying to locate the file in this case, it looks in System32 and cannot find it.

I can provide a full path to this library to solve the issue, however, how can I reference the folder of the executable called by the service in c# ?

CodePudding user response:

I think that is what you're looking for:

System.AppDomain.CurrentDomain.BaseDirectory;

Ref: Should I use AppDomain.CurrentDomain.BaseDirectory or System.Environment.CurrentDirectory?

  • Related