How to get the CommandLine of the Current Application in C# ?

You might need to get the information that contains the commandline which is used to execute the current application in C#.

How to get the CommandLine of the Current Application in C# ?

You can use the CommandLine property of the System.Environment class that provides the necessary information including the application name.

using System;

namespace ACConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Command line of the Abundantcode app is : " + Environment.CommandLine);
            Console.ReadLine();
        }
    }
}

The output of the program would be

Command line of the Abundantcode app is : “c:\users\ac\documents\visual studio 2015\Projects\ACConsoleApp1\ACConsoleApp1\bin\Debug\ACConsoleApp1.vshost.exe”

%d