NetPath




Function GetDriveAndPath(FilePath As String) As String

'Returns the path (without file name,

'but with the drive) from FilePath


Dim intStartPos As Integer
Dim intLength As Integer
Dim strCurrentChar As String
Dim intCurrentChar As Integer

'Determine if the path is from a drive letter or UNC


If Left(FilePath, 2) = "\\" Then
intStartPos = InStr(3, FilePath, "\") - 1
Else
intStartPos = 3
End If

'Find the beginning of the file name (ifthere is no

'file name, there must be a 'trailing "\")


For intCurrentChar = 0 To Len(FilePath)
If Mid(FilePath, Len(FilePath) - intCurrentChar, 1) = "\" Then
Exit For
End If
Next intCurrentChar

intLength = Len(FilePath) - intCurrentChar - intStartPos + 1
GetDriveAndPath = Left(FilePath, Len(FilePath) - intCurrentChar)

End Function










( netpath.html )- by Paolo Puglisi - Modifica del 17/12/2023