Display everything after the 2 last backslashes in a filename

Posted on 2007-10-02
Last Modified: 2010-04-30
Hi Experts
I am trying to setup a recent file list on a menu. I am storing the filename and path in the .tag property.
How can i display just the last folder the filename not the full path? like this:
The full path: C::\Program Files\Calculator\June bids\John Doe, 11125 oak
I want to display this: June bids\John Doe, 11125 oak everything after the last 2 backslashes.

Question by:isnoend2001
    LVL 92

    Accepted Solution

    Hello isnoend2001,

    Dim arr As Variant
    arr = Split(PathVariable, "\")
    Debug.Print arr(UBound(arr) - 1) & "\" & arr(UBound(arr))


    LVL 8

    Expert Comment

    dim p() as String

    p = split(myPathAndFileName,"\")

    debug.Print p(ubound(p-1) & "\" & p(ubound(p))
    LVL 8

    Expert Comment

    ubound(p)-1 , even =)

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
    The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    754 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