I have my Windows Application that accepts args and I use this in order to set up the Window behaviour
problem is that I need to pass text in some of this arguments but my application is looking at it as multiple args, so, this:
"http://www.google.com/" contact 450 300 false "Contact Info" true "Stay Visible" true
has actually 11 arguments instead of the 9 that I am expecting.
What is the trick to get "contact info" and "stay visible" to be passed as only one argument?
Are you running it directly from the command line? If so, I'd expect that to work just fine. (I assume you're using the parameters from the Main method, by the way?)
For instance, here's a small test app:
using System;
class Test
{
static void Main(string[] args)
{
foreach (string arg in args)
{
Console.WriteLine(arg);
}
}
}
Execution:
>test.exe first "second arg" third
first
second arg
third
This is a console app, but there's no difference between that and WinForms in terms of what gets passed to the Main method.
MSDN says, that it should work the way you mentioned.
class CommandLine
{
static void Main(string[] args)
{
// The Length property provides the number of array elements
System.Console.WriteLine("parameter count = {0}", args.Length);
for (int i = 0; i < args.Length; i++)
{
System.Console.WriteLine("Arg[{0}] = [{1}]", i, args[i]);
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With