问题
I have a path string like c:\user\test\test.jpg
, how can I make it c:\\user\\test\\test.jpg
?
回答1:
string s = s.Replace(@"\", @"\\");
回答2:
Try this:
string path = @"c:\user\test\test.jpg";
回答3:
you would only require escaping if you are using string literal in the code. why would you require automatic escaping anyways. you can use @ before the literal that requires no escaping.
回答4:
You can always try something like: System.Text.RegularExpressions.Regex.Unescape, of course that will do all escaped characters.
来源:https://stackoverflow.com/questions/4543686/how-to-automatically-escape-the-path