«

»

Oct 12

How do I retrieve command-line arguments in my WPF application?

The easiest way to retrieve command-line arguments in any (not just WPF) .NET application is to simply call System.Environment.GetCommandLineArgs(). And you can do that at any point in your application not just from the Main method.

using System;

class Sample 
{
    public static void Main() 
    {
        Console.WriteLine();
        String[] arguments = Environment.GetCommandLineArgs();
        Console.WriteLine("GetCommandLineArgs: {0}", String.Join(", ", arguments));
    }
}