Solved

C# - How to obtain the application name

Posted on 2013-06-25
4
329 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 334 total points
ID: 39276805
Try:

System.AppDomain.CurrentDomain.FriendlyName
0
 
LVL 75

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 30

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

Technology Partners: 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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 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