how to automatically escape the path
20,800
Solution 1
string s = s.Replace(@"\", @"\\");
Solution 2
Try this:
string path = @"c:\user\test\test.jpg";
Solution 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.
Author by
user496949
Updated on July 15, 2022Comments
-
user496949 almost 2 years
I have a path string like
c:\user\test\test.jpg
, how can I make itc:\\user\\test\\test.jpg
? -
Admin about 9 yearshow to do opposite of this? and when there are random no of \\ in the path for e.g. how can i make this path C:\\abcdef\\\\smstr\\iretrieval\\20_newsgroups\\20_newsgroups\\alt.atheism\\ as C:\abcdef\smstr\iretrieval\20_newsgroups\20_newsgroups\alt.atheism\?