how to automatically escape the path
-
13-10-2019 - |
Question
I have a path string like c:\user\test\test.jpg
, how can I make it c:\\user\\test\\test.jpg
?
Solution
string s = s.Replace(@"\", @"\\");
OTHER TIPS
Try this:
string path = @"c:\user\test\test.jpg";
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow