I need to replace double quotes with single so that something like this
\\\\servername\\dir1\\subdir1\\
becomes
\\servername\dir1\subdir1\
I tried this
string dir = "\\\\servername\\dir1\\subdir1\\";
string s = dir.Replace(@"\\", @"\");
The result I get is
\\servername\\dir1\\subdir1\\
Any ideas?
You don’t need to replace anything here. The backslashes are escaped, that’s why they are doubled.
Just like
\trepresents a tabulator,\\represents a single\. You can see the full list of Escape Sequences on MSDN.This will output
\\servername\dir1\subdir1\.BTW: You can use the verbatim string to make it more readable: