Reputation: 6899
I am calling one .NET app from another using Process.Start and passing in a bunch of strings as command line arguments:
startInfo.Arguments = String.Join(""" """, MyArray)
Dim p As Process = Process.Start(startInfo)
My intent is to pass in something like:
"first value" "second value" "third value"
and retrieve from within the second app:
Sub Main(ByVal args() as String)
If args.Length > 0 Then
End If
...
End Sub
Unfortunately args.Length only returns 1 - all the values I pass get passed on as a single value: "first value second value third value"
I tried wrapping each in double quotes in the first app but does not seem to help. I know I can just retrieve args(0) and then split it into an array of values but I do not want to do that. Also somehow it worked for me before, even without double quotes. So I am trying to figure out what happened and how can I make it pass my strings as multiple values instead of 1.
Upvotes: 0
Views: 461
Reputation: 2617
Your String.Join is not going to give you what you want. It will not put the double quote at the start and end of the string.
startInfo.Arguments = """" + String.Join(""" """, MyArray) + """"
Upvotes: 2