Executable name

  • Thread starter Thread starter Aryeh Katz
  • Start date Start date
A

Aryeh Katz

How can I determine the full name of a c# executable, like the c
GetModuleFileName?
Thanks.
Aryeh
 
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 GetExecutingAssembly, which will give you the
assembly of the code that called it, or you can use the static
GetEntryAssembly method, which will return the assembly that is the entry
point. For most applications, this assembly is the executable which was
launched.

Hope this helps.
 
Nicholas said:
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 GetExecutingAssembly, which will give you the
assembly of the code that called it, or you can use the static
GetEntryAssembly method, which will return the assembly that is the entry
point. For most applications, this assembly is the executable which was
launched.
Thanks, this is exactly what I need.
Out of curiousity, do you happen to know if the performance is better for
GetExectuingAssembly().Location or
using PInvoke on GetModuleFileName ?
Aryeh
 
Aryeh,

I don't think that GetModuleFileName will give you the results that you
want. That is for DLLs that are native code, not necessarily managed code.
 
Nicholas said:
Aryeh,

I don't think that GetModuleFileName will give you the results that you
want. That is for DLLs that are native code, not necessarily managed code.
I guess what you're saying makes sense.
Thanks.
Aryeh
 
Back
Top