How can i add two backslashes to a string?
hi :)
i'm having trouble putting two backslashes in a string, here's what I was trying to do.. I needed to replace the single backslash in a file path with two backslashes, I have written a little method to do something similar already. for example:
string filelocation = Regex.Replace(prelocation,"\"","");
will replace all double quotes in the string with nothing (in another word it takes out the double quotes) and i know this works
however, with backslashes, it doesn't apear to work...for example
Code:
string filelocation = Regex.Replace(prelocation,"\\","\\\\");
doesnt work. the program stop with an error that says
"Additional information: parsing "\" - Illegal \ at end of pattern."
I've also even tried
Code:
string filelocation = Regex.Replace(prelocation,@"\",@"\\");
which also gives the same error
any help is appreciated!! :rolleyes: