How to find windows service exe path

前端 未结 9 2033
一整个雨季
一整个雨季 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:09

    Instead of using a directory relative to the executable, and therefore needing admin privileges, why not use the common application data directory, which is accessible through

    Environment.GetFolderPath(SpecialFolder.CommonApplicationData)
    

    This way your app doesn't need write access to its own install directory, which makes you more secure.

提交回复
热议问题