Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C# - How to obtain the application name

Posted on 2013-06-25
4
Medium Priority
?
336 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 30

Assisted Solution

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

System.AppDomain.CurrentDomain.FriendlyName
0
 
LVL 75

Assisted Solution

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

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

Open in new window

0
 
LVL 30

Accepted Solution

by:
anarki_jimbel earned 1336 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

636 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