Reputation: 229
I am using SQLDataReader
in C# to query a SQL table. One of the fields in this table is a string that holds a file path, for example "C:\\Files\\MyFiles"
.
However, SQLDataReade
r returns this string with two additional backslashes. For example: "C:\\\\Files\\\\MyFiles"
.
SQLDataReader appears to be detecting the escape character "\". Is there anyway I can stop it doing this?
Upvotes: 2
Views: 666
Reputation: 30042
It is somehow misleading for some developers when inspecting the value in visual studio. You get a string like this:
C:\\\\Files\\\\MyFiles
But when you print it to the console you get the exact string:
Console.WriteLine(path); /* C:\\Files\\MyFiles */
You can click the Magnifier icon to check the exact string characters. So no worries, you're safe to go it is just Visual Studio adding some escape characters.
Upvotes: 2