Results 1 to 4 of 4

Thread: How to I rip the file name from a full path string?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Location
    Malaysia
    Posts
    69
    How to I rip the file name from a full path string?

    eg.
    "c:\Folder\picture.jpg"

    What I want is "picture.jpg". And the path of the picture
    is different depending on the user selection. So, using
    the mid() is somewhat impossible (or maybe not) because of varying length.

    Thx

  2. #2
    New Member
    Join Date
    May 2000
    Location
    Shropshire, England
    Posts
    14

    Red face easy mate, just mundane code

    just use a do while loop and test every charcter backwards untill you come across "\". You can do this with the mid(), then cut the string required using pointers (i%) for the number of characters required.

    any probs send e-mail "[email protected]"
    Were all drowning!

  3. #3
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Give this a whirl

    Code:
    sMaskName = "c:\myFolder\AnotherFolder\MyFile.txt"
    sTest = Dir$(sMaskName, vbNormal) 'loses the path!
    Iain, thats with an i by the way!

  4. #4
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Another alternative - vb6 only

    Code:
    Private Function getTitle(Filename As String) As String
    
    Dim strTemp() As String
    
    strTemp = Split(Filename, "\")
    
    getTitle = strTemp(UBound(strTemp()))
    
    End Function
    Mark
    -------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width