Solved

C# - How to obtain the application name

Posted on 2013-06-25
4
325 Views
Last Modified: 2013-06-26
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.
0
Comment
Question by:tommym121
  • 2
4 Comments
 
LVL 29

Assisted Solution

by:anarki_jimbel
anarki_jimbel earned 334 total points
ID: 39276805
Try:

System.AppDomain.CurrentDomain.FriendlyName
0
 
LVL 74

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 166 total points
ID: 39276812
Alternatively:

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

Open in new window

0
 
LVL 29

Accepted Solution

by:
anarki_jimbel earned 334 total points
ID: 39276838
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
 

Author Closing Comment

by:tommym121
ID: 39277494
Thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now