Pregunta

I am trying to store a string or nvarchar(500) in SQL. When I pass a full file path as a string parameter, there is an error unrecognized escape sequence.

Since path is not an usual param that this stored procedure expects, how can I open this possibility so it can accept string such as c:\foldername\subfoldername. Am I suppose to add @ at the begging of a string or use a StringBuilder?

Thanks

¿Fue útil?

Solución

Since backslash is considered as a special character(escape), it's causing the issue. Use / or \\ in the path as:

      c:/foldername/subfoldername
      c:\\foldername\\subfoldername

OR as you said, use @ in the front as :

     @"c:\foldername\subfoldername"

EDIT: For Javascript, I will simply replace the \ to / as below:

     path = path.split("\\").join("/");

Otros consejos

You can also escape the backslash() by adding the @ to the front of the string for example

@"This\Is\Some\Path"
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top