Tuesday 25 September 2012

Command Line Parameter trailing backlash problem

I am currently working on a small console application which takes in a path name via the Command Line Parameters, parses the given path, and produces an XML file listing each folder and file.

I am running the application as a Post Build event in Visual Studio, passing in the $(TargetDir) macro as;

"c:\Program Files\CreateUpdateXML\CreateUpdateXML.exe" "$(TargetDir)\"

You’ll notice the extra trailing backslash after the Macro.

“Visual studio already adds a trailing backslash though!”

Yes… You’re right… However, a trailing backslash followed by quotation marks is converted to an Escape by Windows.

To work around this issue, you must escape the backslash, forcing windows to use it. This is achieved by simply adding another backslash to the path.

No comments:

Post a Comment