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

Re: Directory of assembly when using services by Arild

Arild
Wed Nov 30 03:35:28 CST 2005

System.Reflection.Assembly.GetExecutingAssembly() returns the current
assembly, and it has properties to get it's location (Codebase, Location...)


Arild

"Michael Groeger" <google.news@web.de> wrote in message
news:e6sIYAZ9FHA.2176@TK2MSFTNGP14.phx.gbl...
> 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
>
>



Re: Directory of assembly when using services by Michael

Michael
Wed Nov 30 03:58:23 CST 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:#9mElFZ9FHA.340@TK2MSFTNGP09.phx.gbl...
> System.Reflection.Assembly.GetExecutingAssembly() returns the current
> assembly, and it has properties to get it's location (Codebase,
Location...)
>
>
> Arild
>
> "Michael Groeger" <google.news@web.de> wrote in message
> news:e6sIYAZ9FHA.2176@TK2MSFTNGP14.phx.gbl...
> > 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
> >
> >
>
>



Re: Directory of assembly when using services by Arild

Arild
Wed Nov 30 04:45:14 CST 2005

Hi,

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


Arild

"Michael Groeger" <google.news@web.de> wrote in message
news:OsjXXSZ9FHA.952@TK2MSFTNGP12.phx.gbl...
> 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:#9mElFZ9FHA.340@TK2MSFTNGP09.phx.gbl...
>> System.Reflection.Assembly.GetExecutingAssembly() returns the current
>> assembly, and it has properties to get it's location (Codebase,
> Location...)
>>
>>
>> Arild
>>
>> "Michael Groeger" <google.news@web.de> wrote in message
>> news:e6sIYAZ9FHA.2176@TK2MSFTNGP14.phx.gbl...
>> > 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
>> >
>> >
>>
>>
>
>



Re: Directory of assembly when using services by Michael

Michael
Wed Nov 30 05:02:55 CST 2005

ok, thanks anyway ;)

"Arild Bakken" <arildb_@hotmail.com> schrieb im Newsbeitrag
news:#npzmsZ9FHA.912@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> I've never used AppDomain.CurrentDomain.BaseDirectory myself, so I really
> don't know :)
>
>
> Arild
>
> "Michael Groeger" <google.news@web.de> wrote in message
> news:OsjXXSZ9FHA.952@TK2MSFTNGP12.phx.gbl...
> > 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:#9mElFZ9FHA.340@TK2MSFTNGP09.phx.gbl...
> >> System.Reflection.Assembly.GetExecutingAssembly() returns the current
> >> assembly, and it has properties to get it's location (Codebase,
> > Location...)
> >>
> >>
> >> Arild
> >>
> >> "Michael Groeger" <google.news@web.de> wrote in message
> >> news:e6sIYAZ9FHA.2176@TK2MSFTNGP14.phx.gbl...
> >> > 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
> >> >
> >> >
> >>
> >>
> >
> >
>
>