Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

i am developing a new windows services and i need to initialize the path like the way we use to do in windows application

Path.GetDirectoryName(Application.ExecutablePath)

but in windows services there is nothing of such type.

and also i need to create the log as i have created the log class now i want the Service name to be logged in the log.txt so how can i find the current service name in my application like using stack trace in windows application and finding the name of a method and a class name.


Thanks in adv.

Tc
Posted

you can find the information of your service in the registry
HKLM\System\CurrentControlSet\Services\--service name--\ImagePath

ooooorrr

you can use this
Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location ) );
 
Share this answer
 
This will get need.

C#
var appPath = Assembly.GetExecutingAssembly().Location;
Debug.WriteLine(Path.GetDirectoryName(appPath));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900