Extract file name from file Path in VB6

Imaging you have Path like:

C:\Program Files\Microsoft.NET\ADOMD.NET\100\db.dll

and you want extract file name “db.dll” from Path, here is the solution:

Private Sub ExtractFileName (sPath As String)
Dim aFName() As String
Dim sPath2 As String
Dim sFileName As String
sPath2 = txtPath2.Text
aFName = Split(sPath, “\”)
sFileName=  aFName(UBound(aFName))

End Sub

Leave a Comment

Your email address will not be published. Required fields are marked *