C# - How to obtain the application name

I have created an C# application  called "Demo.exe"

However, I would like to make a copy of Demo.exe like Demo1.exe, Demo2.exe.

What API allows me to get the name of the application that I execute.

For example,  if I click on Demo1.exe, I would like to get 'Demo1.exe' as the application name within the Demo1.exe application.
tommym121Asked:
Who is Participating?
 
anarki_jimbelConnect With a Mentor Commented:
Alternatively :)

            // assembly file name
            string codebase = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
            string filename = System.IO.Path.GetFileName(codebase);
            MessageBox.Show("File name = " + filename);

            // process name (no .exe extension)
            string processname = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
            MessageBox.Show("Process name = " + processname);

Open in new window

0
 
anarki_jimbelConnect With a Mentor Commented:
Try:

System.AppDomain.CurrentDomain.FriendlyName
0
 
käµfm³d 👽Connect With a Mentor Commented:
Alternatively:

System.IO.Path.GetFileName(System.Environment.GetCommandLineArgs()[0])

Open in new window

0
 
tommym121Author Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.