You can easily get information about the full command used to launch your application, as well as the path to the executable containing your code.
- Environment.CommandLine is a string containing the full command line that launched your application
- Environment.CurrentDirectory is a string containing the full path to the current working directory (which may be different from the directory containing your application)
- Assembly.GetExecutingAssembly().CodeBase is a string containing the full path to the executable or DLL containing the code that is currently executing
For example:
1 2 3 4 5 6 7 8 9 | Console.WriteLine("Your full command line was:");Console.WriteLine(string.Format(" {0}", Environment.CommandLine));Console.WriteLine("Current working directory is:");Console.WriteLine(string.Format(" {0}", Environment.CurrentDirectory));// Requires: using System.Reflection;Console.WriteLine("Full path to executable:");Console.WriteLine(string.Format(" {0}", Assembly.GetExecutingAssembly().CodeBase)); |
If we launch the application as follows:

We’ll see the following output:

We’ll see the following output:

