Working with command line arguments.
-
I am working on a Console application at I wish to use arguments with. I am using VS2005 system.environment.getarguments... This returns a string array separated by a space. This does not help if the arg I am trying to pass has spaces. How to I set the GetArgs to use a - or / as the separate (switch)? At present I am writing the array back as a single string and using split to separate in the - but this is wrong I know. Does anyone have advice / tutorial explaining this. Please NO cut and paste code.... Thanks
When people make you see red, be thankful your not colour blind.
-
I am working on a Console application at I wish to use arguments with. I am using VS2005 system.environment.getarguments... This returns a string array separated by a space. This does not help if the arg I am trying to pass has spaces. How to I set the GetArgs to use a - or / as the separate (switch)? At present I am writing the array back as a single string and using split to separate in the - but this is wrong I know. Does anyone have advice / tutorial explaining this. Please NO cut and paste code.... Thanks
When people make you see red, be thankful your not colour blind.
japel wrote:
This does not help if the arg I am trying to pass has spaces
Arguments usually are preceeded aith an escape character. Either '\', '/', or '-' for example. You can do your split and check out for that escape character at each of the splitted strings. If it starts with your escape char then it's a new argument. As long as it doesn't then simply append it to the previous one.
Regards:rose:
-
japel wrote:
This does not help if the arg I am trying to pass has spaces
Arguments usually are preceeded aith an escape character. Either '\', '/', or '-' for example. You can do your split and check out for that escape character at each of the splitted strings. If it starts with your escape char then it's a new argument. As long as it doesn't then simply append it to the previous one.
Regards:rose:
In the past I have done this with a getargs sub but why is there a system.environment.getarguments if it is so limited. It must be how I am implementing it. This was the way I was doing it.
Function GetCMDArgs() As String() ' Declare variables. Dim separators As String = " " Dim commands As String = Microsoft.VisualBasic.Interaction.Command() Dim CMDargs() As String = commands.Split(separators.ToCharArray) Return CMDargs End Function
When people make you see red, be thankful your not colour blind.