Skip to: Site menu | Main content

Login

Name: 
Password:
Remember me?
Register

Get Filename from path

written by Mark Rowlinson - Last updated Sep 2005

The following function returns the filename without the extension from the file's full path:

 
Function FileName(strPath As String) As String 
    Dim strTemp As String 
    strTemp=mid$(strPath,instrrev(strPath,"\")+1) 
    FileName=left$(strTemp,instrrev(strTemp,".")-1) 
End Function 
 

The following function returns the filename with the extension from the file's full path:
 
Function FileName(strPath As String) As String 
    FileName=mid$(strPath,instrrev(strPath,"\")+1) 
End Function 
 

And while we're at it if you wanted to just get the path you could use:
 
Function FilePath(strPath As String) As String 
    FilePath=left$(strPath,instrrev(strPath,"\")) 
End Function