How to automatically avoid the path

I have a path string, for example c:\user\test\test.jpg , how can I make it c:\\user\\test\\test.jpg ?

+4
source share
3 answers
 string s = s.Replace(@"\", @"\\"); 
+12
source

Try the following:

 string path = @"c:\user\test\test.jpg"; 
+19
source

you only need escaping if you use a string literal in your code. why do you need automatic shielding anyway. you can use @ in front of a literal that does not require escaping.

+6
source

Source: https://habr.com/ru/post/1333538/


All Articles