Windows service - get current directory

后端 未结 4 436
庸人自扰
庸人自扰 2020-12-24 10:42

I have a Windows service that should look for a configuration file in its current directory.

So I use directory.getcurrentdirectiry() but instead of the

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-24 11:03

    Don't use Directory.GetCurrentDirectory(). I had the same exact problem with C:\Windows\System32 being returned. Use this instead:

    Path.GetDirectoryName(Application.ExecutablePath);

提交回复
热议问题