VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Gets only the file name from a file path.

by Tom Parkison (8 Submissions)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 7th September 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Gets only the file name from a file path.

Rate Gets only the file name from a file path.



  Dim i As Long
  For i = 1 To Len(FileName)
    If Left(Right(FileName, i), 1) = "\" Then
      If WithSlash = False Then
        FileNameOnlyFromFullPath = Right(FileName, i - 1)
        Else
        FileNameOnlyFromFullPath = Right(FileName, i)
      End If
      Exit Function
    End If
  Next
End Function

---=== How to Use ===---

' To get the file name with the slash at the left
variable = FileNameOnlyFromFullPath(FILENAME, True)

' To get the file name without the slash at the left
variable = FileNameOnlyFromFullPath(FILENAME, False)

Download this snippet    Add to My Saved Code

Gets only the file name from a file path. Comments

No comments have been posted about Gets only the file name from a file path.. Why not be the first to post a comment about Gets only the file name from a file path..

Post your comment

Subject:
Message:
0/1000 characters