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

x

Replacing backslash with forward slash in a string

jaxrpc
jaxrpc asked
on
Medium Priority
2,243 Views
Last Modified: 2012-08-13
Hi,

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
Comment
Watch Question

Commented:
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

Author

Commented:
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 :(

Commented:
Sorry,

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...

Dave
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.

OR

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.