Reputation: 7197
string DownloadDirectoryPath = @"C:\\Program Files\\companyname\\productname\\username\\0\\2012081617085746"
(this is the path i get from the sql server) but my application uses single slashes so I try to use
DownloadDirectoryPath= DownloadDirectoryPath.Replace(@"\\", @"\");
but this doesn't work and I get the same string. any advice?
PLEASE NOTICE:
the value above is what i see in watch window
Upvotes: 1
Views: 127
Reputation: 44295
The @
tells the compiler to read the string Verbatim. The person that wrote the SQL intended for the string to be interpreted. In order to work with what you have remove the @
string DownloadDirectoryPath = "C:\\Program Files\\companyname\\productname\\username\\0\\2012081617085746"
Also note that when you see a verbatim string in the debugger watch window, you will see the escape characters that were added by the compiler, not the verbatim version from your source code.
Upvotes: 0
Reputation: 13864
You've not got a @ in front of your value for DownloadDirectoryPath, so it's not actually got any \\'s in it, only \'s
Do a console.WriteLine(DownloadDirectoryPath) to check what it really has in it.
Edit (OP updated question):
If you hover over the variable containing it (or use the watch window) while debugging then VS will show a single \ as \\ to disambiguate it from an escape character. Write it to the console, a file or some other output to check what it really is.
Upvotes: 6