Windows service – get current directory

You can set the current directory to the directory that your service is running from by including this line in your code:

System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);

The important part of this is:

System.AppDomain.CurrentDomain.BaseDirectory

That returns the path to the directory your service is running from.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)