Replacing backslash with forward slash in a string

Posted on 2006-03-24
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
Question by:jaxrpc
    LVL 34

    Accepted Solution

    Replace works fine:

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

    Author Comment

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

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

    Expert Comment


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


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    Introduction When many people think of the WebBrowser ( control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now