Skip to content

Latest commit

 

History

History
26 lines (24 loc) · 563 Bytes

File metadata and controls

26 lines (24 loc) · 563 Bytes

Command Line Arguments

Capture with Main() in console applications

static void Main(string[] args)
{
    for (var x = 0; x < args.Count(); x++)
    {
        switch (args[x].Trim().ToLower())
        {
            case "/h":
                doHelp = true;
                break;
        }
    }
}

Capture anywhere (good for Forms)

string[] args = Environment.GetCommandLineArgs();
string argsString = "";
for (int i=0; i<args.Length; i++)
    argsString += $"\n  [{i}] \"{args[i]}\"";
Log($"Command line arguments: {argsString}");