VB.Net string parsing question

Posted on 2007-08-07
Last Modified: 2010-04-23
I'm having trouble parsing this string.

I need to get rid of the filename part of the following string, everything to the right of the last "\".


I'm coding this with VB.Net

Question by:JMO9966
    LVL 38

    Assisted Solution

    Really easy in .NET using the path class

    Dim path As String = "C:\JB\CustData\csv\Neill.csv"

    LVL 96

    Accepted Solution

    Actually, I believe that would be System.IO.Path.GetDirectoryName(path).

    LVL 38

    Expert Comment

    Woops.  Yes, if he actually wants to get *rid* of the filename part, like he says in the question, instead of in the sentence that arrived in my mind...
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    You can also pass the filename to a new FileInfo instance and get the info from that:

            Dim fullPath As String = "C:\JB\CustData\csv\Neill.csv"
            Dim fi As New System.IO.FileInfo(fullPath)
            Dim fileName As String = fi.Name
            Dim filePath As String = fi.DirectoryName

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video discusses moving either the default database or any database to a new volume.

    746 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

    16 Experts available now in Live!

    Get 1:1 Help Now