0

I need to pass the folder path to the Python interface but spaces in the path make it complicated. Example : Defect.py C:\TestImage\Images works fine. However, if there is a space in the path as below,

`Defect.py C:\**Test Image**\Images`

causes an error due to two separate parameters.

If I could pass it as : Defect.py "C:\**Test Image**\Images" should work

So I am currently trying to use string.Format("{0}") to format this string with double quotations but does not work. Please let me know how I could format the statement using string.Format. I need to use string.Format since there are multiple other parameters.

PCG
  • 2,049
  • 5
  • 24
  • 42

1 Answers1

2

Try this:

string.Format("Defect.py \"C:\\{0}\\Images\"", "Test Image");

Bear in mind that the whole trick is to escape the character using the \" backslash escape character. The rest of it was just to show how to use the string.Format

Athanasios Kataras
  • 25,191
  • 4
  • 32
  • 61