Spen D
Spen D

Reputation: 4345

sending values from command line?

hai consider that my application name is sApp.exe

when i run my application as
sApp.exe < myValue>
my application should start and i want to get that myValue in my application
how i can do this?

Upvotes: 0

Views: 78

Answers (1)

Petar Minchev
Petar Minchev

Reputation: 47373

Edit: For WPF use string[] args = Environment.GetCommandLineArgs();

For other applications(not WPF):

static void Main(string[] args)
{
    foreach (string argument in args)
       Console.WriteLine(argument);
}

If you want the first argument use args[0], but be sure to check the length of the array before accessing it.

Upvotes: 2

Related Questions