CodeItBetter Programming Another VB Programming Blog

How to get the folder name alone from a file name

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
'File/Folder Handling - How to get the folder name alone from a file name
Public Function ExtractFolderName(ByVal strFileName As String)
    Dim intPos As Integer
    intPos = InStrRev(strFileName, "\")
    ExtractFolderName = Left$(strFileName, intPos - 1)
End Function
 
'How can I use this function:
'Debug.Print ExtractFolderName("C:\Temp\Test.txt")
'will return "C:\Temp"
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.