How to find windows service exe path

前端 未结 9 1982
一整个雨季
一整个雨季 2020-12-25 09:46

I have a windows service and I need to create directory to store some info. The directory path must be relative to the windows service exe file. How can get this exe file pa

相关标签:
9条回答
  • 2020-12-25 10:10

    This did the trick for me

    Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);    
    
    0 讨论(0)
  • 2020-12-25 10:18

    Tip: If you want to find startup path of installed windows service, look here from registry .

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\ + ServiceName
    

    There are keys about windows service

    0 讨论(0)
  • 2020-12-25 10:19

    You can use AppDomain.CurrentDomain.BaseDirectory

    0 讨论(0)
提交回复
热议问题