In a C# 2008 application, I am creating directory paths like the following in code:
C:\\temp\\testt1\\customer.
I need to be able to save this value in columns in a sql server 2008 r2 database. I
want the above directory to be saved as:
C:\temp\testt1\customer.
I have tried to replace \\ with \ using the replace string function but I am getting escape character errors.
Thus can you tell me how to resolve this problem?
Loading

VulpesRank #55 · 29.2K reputationPosted Oct 16, 2012, 6:42 AM EDT
VulpesRank #55 · 29.2K reputationPosted Oct 16, 2012, 5:59 AM EDT
It should then save in the database as a path with single backslashes
dcRank #2,247 · 627 reputationPosted Oct 16, 2012, 6:11 AM EDT
be C:\temp\testt1\customer in the database?
VulpesRank #55 · 29.2K reputationPosted Oct 16, 2012, 6:15 AM EDT
"C:\\temp\\testt1\\customer"
to the database i.e. with doubled backslashes.
You could also use a 'verbatim' string (preceded by @) with single backslashes:
@"C:\temp\testt1\customer"
Both of these represent the same string in C#.
dcRank #2,247 · 627 reputationPosted Oct 16, 2012, 6:38 AM EDT