Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

How do I get the path to a Windows Service executable

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill Fuller - 06 Mar 2008 06:23 GMT
I tried reading a file into an application running as a Windows Service,
however it is not returning the correct location for the running executable.
How do I determine the full path for this?
Shrihari Devji - 06 Mar 2008 06:49 GMT
Hello

   I think u can get the executable path using
   AppDomain.CurrentDomain.BaseDirectory

Regards

Shrihari Devji

>I tried reading a file into an application running as a Windows Service,
>however it is not returning the correct location for the running
>executable. How do I determine the full path for this?
Sebastian Lopez - 06 Mar 2008 12:30 GMT
Hello,

AppDomain.CurrentDomain.BaseDirectory does not guaranty to return
assembly's path (although it will do it most of the cases).
BaseDirectory is used by the CRL to probe for assemblies and can be
configured when the AppDomain is created.

You can use the following code to get the path:


System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)

Sebastian

On Mar 6, 4:49 am, "Shrihari Devji" <srihari.de...@in.bosch.com>
wrote:
> Hello
>
[quoted text clipped - 8 lines]
> >however it is not returning the correct location for the running
> >executable. How do I determine the full path for this?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.