Parse command line arguments and make them available to an application.

image_pdfimage_print
   
  


<Application
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="CommandLineArgumentSample.App"
    StartupUri="MainWindow.xaml"
    Startup="app_Startup" />

//File:App.xaml.cs
namespace CommandLineArgumentSample
{
    using System;
    using System.Collections;
    using System.Text.RegularExpressions;
    using System.Windows;

    public partial class App : Application
    {
        void app_Startup(object sender, StartupEventArgs e)
        {
            if (e.Args.Length == 0) return;
            foreach (string arg in e.Args)
            {
                Console.WriteLine(arg);
            }
        }
    }
}