I am trying to pass the file path to the C# Console Application , but I am having problems with the wrong string by the time the console application is reached.
If I started the application from the command line with the file path parameter:
MyApp "C:\Users\DevDave\Documents\Visual Studio 2012\Projects\MyProject\"
A Windows dialog box will appear and inform that my application has stopped working, and when I click the Debug option, I see that the result of args[0] is:
C: \ Users \ DevDave \ Documents \ Visual Studio 2012 \ Projects \ MyProject "
Note that there is still a trailing quote at the end.
If I pass the second argument:
MyApp "C:\Users\DevDave\Documents\Visual Studio 2012\Projects\MyProject\" "any old string"
I get the error message again, and after looking in the debugging, I see that args [0]:
C: \ Users \ DevDave \ Documents \ Visual Studio 2012 \ Projects \ MyProject "any
I'm confused why this is happening. My only assumption is that the backslash in the string causes some sort of escape sequence from the string? Change I noticed that the same thing happens in the above line example! It seems to be having problems here.
I just want to transfer the file path of the current solution directory and call my application from the pre-build event using $ (SolutionDir), and I know that I can get the path to the current solution in other ways. But this is easiest, and I am curious why it is not working properly.
source share