c# – Unrecognized escape sequence for path string containing backslashes

c# – Unrecognized escape sequence for path string containing backslashes

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:ProjectsSomeKindOfPathproblemwuhoo.xml;

Try this:

string foo = @D:ProjectsSomeKindOfPathproblemwuhoo.xml;

The problem is that in a string, a is an escape character. By using the @ sign you tell the compiler to ignore the escape characters.

You can also get by with escaping the :

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

c# – Unrecognized escape sequence for path string containing backslashes

var foo = @D:ProjectsSomeKindOfPathproblemwuhoo.xml;

Leave a Reply

Your email address will not be published.