On the Assembly class, there is a Location property you can use to get
the location of the assembly. Now, to get the assembly to get the property
of, you can use the static GetExecutingAss embly, which will give you the
assembly of the code that called it, or you can use the static
GetEntryAssembl y method, which will return the assembly that is the entry
point. For most applications, this assembly is the executable which was
launched.
"Aryeh Katz" <ank@secure-services.com> wrote in message
news:OfG4QxDtDH A.540@tk2msftng p13.phx.gbl...[color=blue]
> How can I determine the full name of a c# executable, like the c
> GetModuleFileNa me?
> Thanks.
> Aryeh
>[/color]
Nicholas Paldino [.NET/C# MVP] wrote:
[color=blue]
> Aryeh,
>
> On the Assembly class, there is a Location property you can use to get
> the location of the assembly. Now, to get the assembly to get the property
> of, you can use the static GetExecutingAss embly, which will give you the
> assembly of the code that called it, or you can use the static
> GetEntryAssembl y method, which will return the assembly that is the entry
> point. For most applications, this assembly is the executable which was
> launched.
>[/color]
Thanks, this is exactly what I need.
Out of curiousity, do you happen to know if the performance is better for
GetExectuingAss embly().Locatio n or
using PInvoke on GetModuleFileNa me ?
Aryeh
"Aryeh Katz" <ank@secure-services.com> wrote in message
news:OecUa7EtDH A.2400@tk2msftn gp13.phx.gbl...[color=blue]
> Nicholas Paldino [.NET/C# MVP] wrote:
>[color=green]
> > Aryeh,
> >
> > On the Assembly class, there is a Location property you can use to[/color][/color]
get[color=blue][color=green]
> > the location of the assembly. Now, to get the assembly to get the[/color][/color]
property[color=blue][color=green]
> > of, you can use the static GetExecutingAss embly, which will give you the
> > assembly of the code that called it, or you can use the static
> > GetEntryAssembl y method, which will return the assembly that is the[/color][/color]
entry[color=blue][color=green]
> > point. For most applications, this assembly is the executable which was
> > launched.
> >[/color]
> Thanks, this is exactly what I need.
> Out of curiousity, do you happen to know if the performance is better for
> GetExectuingAss embly().Locatio n or
> using PInvoke on GetModuleFileNa me ?
> Aryeh
>[/color]
Nicholas Paldino [.NET/C# MVP] wrote:
[color=blue]
> Aryeh,
>
> I don't think that GetModuleFileNa me will give you the results that you
> want. That is for DLLs that are native code, not necessarily managed code.
>
>[/color]
I guess what you're saying makes sense.
Thanks.
Aryeh
Comment