Reputation: 259
i have a string /Images/Me.jpg
i want to replace forward slashes with backward slashes like this \Images\Me.jpg
, iam using string.Replace("/","\"); but the output is \\Images\\Me.jpg
please help
Upvotes: 19
Views: 55346
Reputation: 43300
you need to escape the slashes
string.Replace("/", "\\")
string.Replace("/", @"\")
Visual studios intellisense will still show "\\", if you hover over the string, you will find a magnifying glass, click it. This will show the real string
Upvotes: 48