views:

55

answers:

1

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?

+2  A: 

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.

Petar Minchev
hai peter i just did wat u said.. but i can give my value with the exe ... i tried like sApp.exe myval but it doesnt get my value... how to give the values???
deep
For the first real argument(not the sApp.exe) use args[1]. If you want the full line(which I doubt) use Environment.CommandLine.
Petar Minchev