Getting full path for Windows Service


Question

How can I find out the folder where the windows service .exe file is installed dynamically?

Path.GetFullPath(relativePath);

returns a path based on C:\WINDOWS\system32 directory.

However, the XmlDocument.Load(string filename) method appears to be working against relative path inside the directory where the service .exe file is installed to.

1
58
10/14/2008 3:49:22 AM

Accepted Answer

Try

System.Reflection.Assembly.GetEntryAssembly().Location
83
10/14/2008 4:03:58 AM

Try this:

AppDomain.CurrentDomain.BaseDirectory

(Just like here: How to find windows service exe path)


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon