或者
Private Function GetParentFolder(path As String) As String
GetParentFolder = Left(path, InStrRev(path, "\"))
End Function
或者
Private Function GetParentFolder(path As String) As String
Dim itemp As Integer
Dim vartemp
Dim varGroup
varGroup = Split(path, "\")
itemp = -1
For Each vartemp In varGroup
itemp = itemp + 1
Next
GetParentFolder = ""
For i = 0 To itemp - 1
GetParentFolder = GetParentFolder + varGroup(i) + "\"
Next i
End Function
Function GetFilePath(ByVal FileName As String) As String
dim intA as Long
intA = InStr(1, FileName, "\")
Do Until intA = 0
intA = InStr(intA + 1, FileName, "\")
Loop
GetFilePath = Left(FileName, intA)
End Function
Function GetPath(fullpath)
Dim p
For p=Len(fullpath) To 1 Step -1
If Mid(fullpath,p,1)="\" Then Exit For
Next
if p=1 Then
GetPath=""
Else
GetPath=Mid(fullpath,1,p-1)
End if
End Function