WPF: Working with command line arguments
I am simplifying the logic we have in our application to showcase here and it is pretty much same as what Avi has shown.
public static string commandArgs = string.Empty;
protected override void OnStartup(StartupEventArgs e)
{
if (e.Args!= null && e.Args.Length > 0)
{
commandArgs = e.Args[0];
}
}
We have some custom file extension that we have associated with our application. And on double clicking such a file, our application launches and we still very much get the file name as part of command line arguments, without having to worry about accesssing it from AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0].
And we have been working with .net 3.5 and our code works both without SP1 and with SP1
