Private Sub SplitPath(ByVal Fullpath As String, _
Drive As String, _
Path As String, _
FileTitle As String)
' Teilt einen in Fullpath übergebenen Pfad in _
Laufwerk, Pfad u. DateiName auf.
' Drive, Path u. FileTitle werden als leere Strings _
übergeben und werden von SplitPath entspr. gefüllt.
Const DirSep = "\"
Dim i As Integer
On Error GoTo Fehler
Drive = ""
Path = ""
FileTitle = ""
' Doppelpunkt nach _
Laufwerksbuchstabe suchen
i = InStr(Fullpath, ":")
If i > 0 Then
Drive = Left$(Fullpath, i)
Fullpath = Mid$(Fullpath, i + 1)
If Left$(Fullpath, 1) = DirSep Then
Fullpath = Mid$(Fullpath, 2)
End If
Else
' kein ":" gefunden, _
Prüfen ob der Pfad mit "\\" beginnt, _
also ein UNC-Pfad (Netzwerkpfad) ist.
If Left$(Fullpath, 1) = DirSep Then
If Not (Mid$(Fullpath, 2, 1) = DirSep) Then
' ungültige Pfadangabe, _
nur einen führenden "\" gefunden
Exit Sub
End If
End If
End If
'Prüfen ob Multiselect genutzt wird
If InStr(Fullpath, Chr$(0)) <> 0 And Not Left$(Fullpath, 1) = Chr$(0) Then
For i = 1 To Len(Fullpath)
If Mid$(Fullpath, i + 1, 1) = Chr$(0) Then
Exit For
End If
Next i
Else
'Nur eine Datei ausgewählt
i = InStrRev(Fullpath, "\")
End If
If i Then
FileTitle = Mid$(Fullpath, i + 1)
Path = Left$(Fullpath, Len(Fullpath) - Len(FileTitle))
Else
' nur Laufwerk und Dateiname
FileTitle = Fullpath
End If
On Error GoTo 0
Exit Sub
Fehler:
End Sub