application name

  • Thread starter Thread starter Chang
  • Start date Start date
C

Chang

how to get the name of a running application using C#

e.g. if i have 20 dll files and my application name is MyGreatApplication
then how to get the name "MyGreatApplication" at runtime?

thx in adv.
c
 
Chang

Have a look at the Application.ProductName attribute. Something like this:

/* ******************************* */
static void Main()
{
string appName = Application.ProductName;
Application.Run(new MyFirstForm());
}
/* ******************************* */

regards
roy fine
 
The ProductName is linked to several different code-paths including attributes
and/or the type
that contains the entry point for the executable. Because you can change the
name through the
resources, you may or may not want to simply use the entry point type.

Assembly main = Assembly.GetEntryAssembly();
if ( main != null ) { return main.EntryPoint.ReflectedType; }

That'll give you the type hosting the entry point and should be very stable.
Unless you often
change class names.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top