Monday, June 12, 2006

Get the application exe name


The following are the different ways we can get the current exe name through code.

Method 1
System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].Name;

This returns the exe name.

Method 2
Application.ExecutablePath

This returns the path with exe name

Method 3
Environment.GetCommandLineArgs()[0]

This returns path with the exe name.

2 Comments:

At 10:25 AM, Blogger Valan said...

Hi Peepa,

this also gives the same

System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;

 
At 10:26 AM, Blogger Valan said...

When ur developing Console application, this will be useful.

 

Post a Comment

<< Home