Determine application directory in a Windows Service

  • Thread starter Thread starter Buddy Ackerman
  • Start date Start date
B

Buddy Ackerman

I need to programatically determine the directory that the application/service is running from. If I use
Environment.CurrentDirectory it returns the System32 directory. Is there anyway to get this the correct directory?
 
Try:
System.Reflection.Assembly.GetExecutingAssembly().CodeBase
or
System.Reflection.Assembly.GetExecutingAssembly().Location

whichever you prefer for your situation. That will tell you where your
..NET service executable is.
 
Back
Top