Showing posts with label C# Service. Show all posts
Showing posts with label C# Service. Show all posts

Thursday, February 14, 2008

Windows Service startup path

Ever wondered how to find the startup path for a windows service?
As in windows application,we can never find the startup path of an application using

Application.StartupPath in windows service.

We can find the startup path of a windows service using Reflection.Include the given code in your service and get the startup path returned.

private string StartPath
{
get
{
return System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly()
.GetName().CodeBase).Substring(6);
}
}

Hope this helps..