?
Solved

C# - How to obtain the application name

Posted on 2013-06-25
4
Medium Priority
?
332 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

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