0

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
  • 5
    What language are you developing your application in? Commented Mar 31, 2010 at 14:03
  • am using c# in my application Commented Mar 31, 2010 at 14:07

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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???
For the first real argument(not the sApp.exe) use args[1]. If you want the full line(which I doubt) use Environment.CommandLine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.