0

I am doing a webcam project and i tried to use c# to run a python script with a location variable passed to python so i can keep changing the opening/saving location of the images.

This is used to pass the location of the opening of image to do a cropping.

string loca = File.ReadAllText("cropface.py").Replace("%location%", "C:\\Users\\L31101\\Desktop\\Camera\\Camera\\bin\\Debug\\center\\center.jpg");
            File.WriteAllText("cropface.py", loca);

However my python script receive the location without 2 backslash

image =  Image.open("C:\Users\L31101\Desktop\Camera\Camera\bin\Debug\center\center.jpg")

Therefore, i tried passing forward slash instead of 2 backslash however my python script still receive 1 backslash.

Any idea how to go around it?

Jing Sian
  • 13
  • 1
  • 4
  • 2
    Instead of `"C:\\Users\\L31101\\Desktop\\Camera\\Camera\\bin\\Debug\\center\\center.jpg");` try `@"C:\\Users\\L31101\\Desktop\\Camera\\Camera\\bin\\Debug\\center\\center.jpg");`. Then two backslashed will be passed. –  Jul 31 '14 at 06:36
  • fell free to accept the anwser if helped :) –  Jul 31 '14 at 06:51

1 Answers1

0

Instead of

"C:\\Users\\L31101\\Desktop\\Camera\\Camera\\bin\\Debug\\center\\center.jpg";

try

@"C:\\Users\\L31101\\Desktop\\Camera\\Camera\\bin\\Debug\\center\\center.jpg";.

Then two backslashed will be passed.

More in this post.

Community
  • 1
  • 1