Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unrecognized escape sequence for path string containing backslashes

The following code generates a compiler error about an "unrecognized escape sequence" for each backslash:

string foo = "D:\Projects\Some\Kind\Of\Pathproblem\wuhoo.xml"; 

I guess I need to escape backslash? How do I do that?

like image 284
Kjensen Avatar asked Aug 19 '09 22:08

Kjensen


1 Answers

You can either use a double backslash each time

string foo = "D:\\Projects\\Some\\Kind\\Of\\Pathproblem\\wuhoo.xml"; 

or use the @ symbol

string foo = @"D:\Projects\Some\Kind\Of\Pathproblem\wuhoo.xml"; 
like image 73
Brandon Avatar answered Oct 24 '22 15:10

Brandon