I have a path string like c:\user\test\test.jpg
, how can I make it c:\\user\\test\\test.jpg
?
Three Ways to Escape Spaces on WindowsBy enclosing the path (or parts of it) in double quotation marks ( ” ). By adding a caret character ( ^ ) before each space. (This only works in Command Prompt/CMD, and it doesn't seem to work with every command.) By adding a grave accent character ( ` ) before each space.
A character with a backslash (\) just before it is an escape sequence or escape character.
However, note that R will add a "\n" at the end of each line break. This is called an escape character, and the n character indicates a new line.
Try this:
string path = @"c:\user\test\test.jpg";
string s = s.Replace(@"\", @"\\");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With