We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Replacing backslash with forward slash in a string

jaxrpc asked
Medium Priority
Last Modified: 2012-08-13

How do i replace a backslash with a forward slash in a string?

say... C:\apple\test to C:/apple/test

i know the string replace method can do this...but i am kinda of lost when replacing characters like / \ * |
if possible please provide a sample on the function based on my problem....thanks
Watch Question

Replace works fine:

        Dim s As String = "C:\test\it"
        MsgBox(s.Replace("\", "/"))

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


weird but it is not working for me.........when i copy and paste your codes...it worked fine...
but when i used it on my string....no changes at all

"file:///C:\testing\123" after stringHere.replace("\","/") still the same.....no changes :(


I had trouble with my notifs yesterday.

I can't see how it's not working..

I just tested

        Dim s As String = "file:///C:\testing\123"
        MessageBox.Show(s.Replace("\", "/"))

in VS 2003 and 2005 and both produced results as expected...

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.