How do you get the arguments in C#, when you send in pipelined arguments?
like
dir /S /B | someprogram.exe
How will someprogram be able to get the values returned from dir /S /B ?
How do you get the arguments in C#, when you send in pipelined arguments?
like
dir /S /B | someprogram.exe
How will someprogram be able to get the values returned from dir /S /B ?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
jesusPosted Jun 10, 2008, 9:59 PM
I know how to get the command line arguments I just don't know how to get the pipelined arguments.
Jan MontanoPosted Jun 10, 2008, 9:38 PM
In a console program...
class Program
{
static void Main(string[] args)
{
//args.Length
}
}
you read the arguments by traversing the args array in Program.cs. where args.Length is the number of arguments passed in you exe.
In a windows app
static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
//static void Main()
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
you just change the parameterless Main method into a parametered one specifying a string array. Then read it just the same as you read it in the console program.