Directory of assembly when using services

  • Thread starter Thread starter Michael Groeger
  • Start date Start date
M

Michael Groeger

Hi all,

normally, when starting a service the current directory
(System.Environment.CurrentDirectory) is the system directory of the
platform. The service itself can be started from another location e.g.
c:\foo\bar\myservice.exe . Is there a way to get the directory the service
executable was started from, in my example c:\foo\bar\?

Kind regards and thanks for your help in advance,
Michael
 
System.Reflection.Assembly.GetExecutingAssembly() returns the current
assembly, and it has properties to get it's location (Codebase, Location...)


Arild
 
Hi Arild,

thanks for your reply. I just tried
System.AppDomain.CurrentDomain.BaseDirectory. I found this solution in
log4net implementation because my logfile was written at the proper place,
but I did not use absolute paths in the configuration. It seems to work
fine, but whats the difference between your solution and my one?

Regards,
Michael
 
Hi,

I've never used AppDomain.CurrentDomain.BaseDirectory myself, so I really
don't know :)


Arild
 
Back
Top