Environment.GetCommandLineArgs() splits string with spaces in it sometimes but not others, want to avoid this.
EXAMPLE 1: command Line Arg (WRONG)
@rpt=D:Test.rpt,@dsn=Test.dsn,@export=pdf,@destination=D:\AutoRpt\Test.pdf,@@startd=-1,@@endd=0,@@whichclient=Joe Bloggs,@Email=no,@EmailParam=1
Gives this
1 = "@rpt=D:Test.rpt,@dsn=Test.dsn,@export=pdf,@destination=D:\AutoRpt\Test.pdf,@@startd=-1,@@endd=0,@@whichclient=Joe"
2 = "Bloggs,@Email=no,@EmailParam=1"
But want it to give this:
1 = "@rpt=D:Test.rpt,@dsn=Test.dsn,@export=pdf,@destination=D:\AutoRpt\Test.pdf,@@startd=-1,@@endd=0,@@whichclient=Joe Bloggs,@Email=no,@EmailParam=1"
EXAMPLE 2: command Line Arg (WORKS)
"@rpt=D:Test.rpt,@dsn=Test.dsn,@export=pdf,@destination=D:\AutoRpt\Test.pdf,@@startd=-1,@@endd=0,@@whichclient=Joe Bloggs,@Email=no,@EmailParam=1"
Gives this
1 = "@rpt=D:Test.rpt,@dsn=Test.dsn,@export=pdf,@destination=D:\AutoRpt\Test.pdf,@@startd=-1,@@endd=0,@@whichclient=Joe Bloggs,@Email=no,@EmailParam=1"
EXAMPLE 3: command Line Arg (WORKS)
"this is a test" string to see "what happens"
Gives this:
1 = this is a test
2 = string
3 = to
4 = see
5 = what happens
Workaround for EXAMPLE 1: join array elements when next array element's first char isn't a "@"
Is there a delimiter that can be used to avoid this?
I've tried these in the above command line, to no avail:
'Joe Bloggs'
"Joe Bloggs"
""Joe Bloggs""
[Joe Bloggs]
Joe\ Bloggs
\"Joe Bloggs\"
P.S. This was a VB6 command line app that I just converted to VB.net & the behaviour only occurs in the VB.net version. It's being called in many places at the moment, so don't really want to have to manually go through all calls & add double quotes around the whole argument.
EXAMPLE 1: command Line Arg (WRONG)
@rpt=D:Test.rpt,@dsn=Test.dsn,@export=pdf,@destination=D:\AutoRpt\Test.pdf,@@startd=-1,@@endd=0,@@whichclient=Joe Bloggs,@Email=no,@EmailParam=1
Gives this
1 = "@rpt=D:Test.rpt,@dsn=Test.dsn,@export=pdf,@destination=D:\AutoRpt\Test.pdf,@@startd=-1,@@endd=0,@@whichclient=Joe"
2 = "Bloggs,@Email=no,@EmailParam=1"
But want it to give this:
1 = "@rpt=D:Test.rpt,@dsn=Test.dsn,@export=pdf,@destination=D:\AutoRpt\Test.pdf,@@startd=-1,@@endd=0,@@whichclient=Joe Bloggs,@Email=no,@EmailParam=1"
EXAMPLE 2: command Line Arg (WORKS)
"@rpt=D:Test.rpt,@dsn=Test.dsn,@export=pdf,@destination=D:\AutoRpt\Test.pdf,@@startd=-1,@@endd=0,@@whichclient=Joe Bloggs,@Email=no,@EmailParam=1"
Gives this
1 = "@rpt=D:Test.rpt,@dsn=Test.dsn,@export=pdf,@destination=D:\AutoRpt\Test.pdf,@@startd=-1,@@endd=0,@@whichclient=Joe Bloggs,@Email=no,@EmailParam=1"
EXAMPLE 3: command Line Arg (WORKS)
"this is a test" string to see "what happens"
Gives this:
1 = this is a test
2 = string
3 = to
4 = see
5 = what happens
Workaround for EXAMPLE 1: join array elements when next array element's first char isn't a "@"
Is there a delimiter that can be used to avoid this?
I've tried these in the above command line, to no avail:
'Joe Bloggs'
"Joe Bloggs"
""Joe Bloggs""
[Joe Bloggs]
Joe\ Bloggs
\"Joe Bloggs\"
P.S. This was a VB6 command line app that I just converted to VB.net & the behaviour only occurs in the VB.net version. It's being called in many places at the moment, so don't really want to have to manually go through all calls & add double quotes around the whole argument.