Windows service - get current directory

后端 未结 4 439
庸人自扰
庸人自扰 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条回答
  •  猫巷女王i
    2020-12-24 11:11

    Getting directory from full path:

    var location = System.Reflection.Assembly.GetEntryAssembly().Location;
    var directoryPath = Path.GetDirectoryName(location);
    

    Quite a silly problem when comparing to writing a Windows service :)

提交回复
热议问题