I am trying to build a Windows service that launches a webserver (Nginx) before login on a Windows computer. This needs to be bundled with the install.
I can find out where the working directory of the windows service is by outputting to a the log the working directory (in this case C:\WINDOWS\System32
) and copy over Nginx directory into that folder but this is not great for when it comes to bundling the application into a setup.exe file which may be installed in any arbitrary location - plus it clutters the Syste开发者_运维问答m32
folder
What is the best way to refer to a set 'external' files both during debugging (i.e. within the solution folder hierarchy) and so that the paths will still work after deployment?
What I normally do is make sure they are in the same folder as the executable. When debugging, you can force this by setting the Copy to output directory
flag in the properties pane for the files you require. When installing, simply make sure that all files are installed in the same folder. The installer should be able to take care of this.
精彩评论