vb6 get file from path

Posted on 2009-02-16
Last Modified: 2012-05-06
I am using VB6. i have a string that contains a path + file name.
such as c:\temp\some folder\
what is the best way to get the

Question by:XK8ER
    LVL 13

    Expert Comment


    good morning!
    u can use the file system object..

    try this approach....

    Public FSO As New FileSystemObject

    FSO.getFile "c:\temp\some folder\"

    then you will get the file ""

    i hope i can give u some idea...

    LVL 1

    Author Comment

    im trying this but its not working!

    lblFile.Caption = FSO.GetFile("c:\temp\some folder\")
    LVL 13

    Expert Comment


    are u trying the put the name of the file to the label caption?

    this is the way to do it...

    dim myFile as File

    myFile = FSO.getFile "c:\temp\some folder\"
    lblFile.Caption = myFile.Name

    *** if u want to know other information about the file, just select when you type the " . " after the myFile

    i hope i can give u idea.

    LVL 92

    Accepted Solution

    Debug.Print Mid(SomeString, InStrRev(SomeString, "\") + 1)

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
    Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    755 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

    26 Experts available now in Live!

    Get 1:1 Help Now