Replace backslash with double backslash using Regex

Jan 9 2004 11:19 PM
I want to replace single back slashes in a string with double back slashes. This is for a database string I pass into an API method call. The following causes a run-time error: public static string setDoubleFSlash(string sPath) { return Regex.Replace(sPath,"\\","\\\\"); } Now I use an extra back slash to escape the actual back slash. HELP! [email protected]

Answers (4)