Getting full path for Windows Service
问题 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: Try System.Reflection.Assembly.GetEntryAssembly().Location 回答2: Try this: AppDomain.CurrentDomain.BaseDirectory (Just like here: How to find windows