string webPath = folderPath.Replace("\", "/");
Hi, I'm trying to replace the above but struggling. Will I need an apply an escape sequence to /. If so anyone know what it is in c#. Any help/hints much appreciated.
string webPath = folderPath.Replace("\", "/");
Hi, I'm trying to replace the above but struggling. Will I need an apply an escape sequence to /. If so anyone know what it is in c#. Any help/hints much appreciated.
string webPath = folderPath.Replace("\\", "/");
... would also work.
As others have said, you have to escape the \ but not the /, and you can avoid the escaping entirely using a verbatim string literal - a string literal prefixed by @ which allows multi-line string constants, and doesn't escape any characters other than " which needs to be doubled.
See my (somewhat old, but still accurate in this case) C# FAQ for a full list of escape sequences.