Pages

Men

rh

7/21/2012

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

How do I retrieve command-line arguments in my WPF application?
Command-line arguments are typically retrieved via a string array parameter passed to Main, but the common way to define WPF applications doesn’t allow you to implement the Main method. You can get around this in two different ways. One way is to forego defining an Application-derived class in XAML, so you can manually define the Main method with a string array parameter. 

The easier way, however, is to simply call System.Environment.GetCommandLineArgs at any point in your application, which returns the same string array you’d get inside Main.

No comments :

Post a Comment