Very weird params passing error to main Method
I have a tool to which I pass arguments via the command line. It is three arguments, the first one is a name, the second and third ones are paths. Now these paths can be such with spaces in them. So I pass them using double-quotes. Let's say I pass the following:
.\myprogram.exe SomeName "C:\Projects\My Project\src" "C:\Projects\My Project\src\bin\x64\SomeProgram.exe"
Now I would expect to receive
But what I get instead is
So the third argument does not get recognized correctly and is split at the space for some reason. I have tried everything. Using double quotes for all three arguments, using no quotes at all, escaping all possible characters... I just don't understand that behaviour.4 Replies
Works on my machine
What's the actual code that gives you this weird result?
are you starting the tool from cmd or what
Basically the same, for debugging reasons I have added a console.WriteLine for all three args. I have also tried opening the code and putting a breakpoint right at the beginning of the main method so I can explore the args array. Which shows me the same results. And it not only happens when I start the program from command line but also when I start it in Rider using the launchSettings.json file to pass the arguments. Same issue
Dammit. I found the issue.
The second parameter actually had a \ at the end. Which was interpreted as an escape character for the closing " of the second argument
Sometimes you just have to write it down to find it yourself.
Thanks for rubberducking guys