PC Review


Reply
Thread Tools Rate Thread

Directory of assembly when using services

 
 
Michael Groeger
Guest
Posts: n/a
 
      30th Nov 2005
Hi all,

normally, when starting a service the current directory
(System.Environment.CurrentDirectory) is the system directory of the
platform. The service itself can be started from another location e.g.
c:\foo\bar\myservice.exe . Is there a way to get the directory the service
executable was started from, in my example c:\foo\bar\?

Kind regards and thanks for your help in advance,
Michael


 
Reply With Quote
 
 
 
 
Arild Bakken
Guest
Posts: n/a
 
      30th Nov 2005
System.Reflection.Assembly.GetExecutingAssembly() returns the current
assembly, and it has properties to get it's location (Codebase, Location...)


Arild

"Michael Groeger" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi all,
>
> normally, when starting a service the current directory
> (System.Environment.CurrentDirectory) is the system directory of the
> platform. The service itself can be started from another location e.g.
> c:\foo\bar\myservice.exe . Is there a way to get the directory the service
> executable was started from, in my example c:\foo\bar\?
>
> Kind regards and thanks for your help in advance,
> Michael
>
>



 
Reply With Quote
 
Michael Groeger
Guest
Posts: n/a
 
      30th Nov 2005
Hi Arild,

thanks for your reply. I just tried
System.AppDomain.CurrentDomain.BaseDirectory. I found this solution in
log4net implementation because my logfile was written at the proper place,
but I did not use absolute paths in the configuration. It seems to work
fine, but whats the difference between your solution and my one?

Regards,
Michael

"Arild Bakken" <arildb_@hotmail.com> schrieb im Newsbeitrag
news:#(E-Mail Removed)...
> System.Reflection.Assembly.GetExecutingAssembly() returns the current
> assembly, and it has properties to get it's location (Codebase,

Location...)
>
>
> Arild
>
> "Michael Groeger" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi all,
> >
> > normally, when starting a service the current directory
> > (System.Environment.CurrentDirectory) is the system directory of the
> > platform. The service itself can be started from another location e.g.
> > c:\foo\bar\myservice.exe . Is there a way to get the directory the

service
> > executable was started from, in my example c:\foo\bar\?
> >
> > Kind regards and thanks for your help in advance,
> > Michael
> >
> >

>
>



 
Reply With Quote
 
Arild Bakken
Guest
Posts: n/a
 
      30th Nov 2005
Hi,

I've never used AppDomain.CurrentDomain.BaseDirectory myself, so I really
don't know


Arild

"Michael Groeger" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Arild,
>
> thanks for your reply. I just tried
> System.AppDomain.CurrentDomain.BaseDirectory. I found this solution in
> log4net implementation because my logfile was written at the proper place,
> but I did not use absolute paths in the configuration. It seems to work
> fine, but whats the difference between your solution and my one?
>
> Regards,
> Michael
>
> "Arild Bakken" <arildb_@hotmail.com> schrieb im Newsbeitrag
> news:#(E-Mail Removed)...
>> System.Reflection.Assembly.GetExecutingAssembly() returns the current
>> assembly, and it has properties to get it's location (Codebase,

> Location...)
>>
>>
>> Arild
>>
>> "Michael Groeger" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Hi all,
>> >
>> > normally, when starting a service the current directory
>> > (System.Environment.CurrentDirectory) is the system directory of the
>> > platform. The service itself can be started from another location e.g.
>> > c:\foo\bar\myservice.exe . Is there a way to get the directory the

> service
>> > executable was started from, in my example c:\foo\bar\?
>> >
>> > Kind regards and thanks for your help in advance,
>> > Michael
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
Michael Groeger
Guest
Posts: n/a
 
      30th Nov 2005
ok, thanks anyway

"Arild Bakken" <arildb_@hotmail.com> schrieb im Newsbeitrag
news:#(E-Mail Removed)...
> Hi,
>
> I've never used AppDomain.CurrentDomain.BaseDirectory myself, so I really
> don't know
>
>
> Arild
>
> "Michael Groeger" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi Arild,
> >
> > thanks for your reply. I just tried
> > System.AppDomain.CurrentDomain.BaseDirectory. I found this solution in
> > log4net implementation because my logfile was written at the proper

place,
> > but I did not use absolute paths in the configuration. It seems to work
> > fine, but whats the difference between your solution and my one?
> >
> > Regards,
> > Michael
> >
> > "Arild Bakken" <arildb_@hotmail.com> schrieb im Newsbeitrag
> > news:#(E-Mail Removed)...
> >> System.Reflection.Assembly.GetExecutingAssembly() returns the current
> >> assembly, and it has properties to get it's location (Codebase,

> > Location...)
> >>
> >>
> >> Arild
> >>
> >> "Michael Groeger" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> > Hi all,
> >> >
> >> > normally, when starting a service the current directory
> >> > (System.Environment.CurrentDirectory) is the system directory of the
> >> > platform. The service itself can be started from another location

e.g.
> >> > c:\foo\bar\myservice.exe . Is there a way to get the directory the

> > service
> >> > executable was started from, in my example c:\foo\bar\?
> >> >
> >> > Kind regards and thanks for your help in advance,
> >> > Michael
> >> >
> >> >
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to start directory services; using directory recovery conso =?Utf-8?B?SnVzdGluIEFsbGVu?= Microsoft Windows 2000 Active Directory 0 8th Sep 2004 12:33 AM
Active Directory directory services administrative tools Daane Clifford Windows XP Security 0 20th Aug 2003 11:33 PM
assembly directory Ryan Moore Microsoft ASP .NET 1 8th Aug 2003 05:43 PM
Assembly's / Web Services C Microsoft Dot NET 0 30th Jul 2003 12:23 AM
Assembly's / Web Services in .Net C Microsoft Dot NET 0 29th Jul 2003 08:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:12 AM.