Getting full path for Windows Service

Samuel Kim picture Samuel Kim · Oct 14, 2008 · Viewed 75.1k times · Source

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.

Answer

Greg Dean picture Greg Dean · Oct 14, 2008

Try

System.Reflection.Assembly.GetEntryAssembly().Location