Попробуйте это
Private Function GetRootDir(ByVal inputString As String) As Integer
'min real path is c:\. We need a len of at least 2
If Len(inputString) < 2 Then
GetRootDir = ""
End If
Dim t As Integer, s As Integer
t = InStr(1, inputString, "\")
If t < 1 Then
GetRootDir = ""
Exit Function
End If
s = InStr(t + 1, inputString, "\")
'If this is the root folder that was selected
If s < 1 Then
GetRootDir = Mid(inputString, t + 1)
Exit Function
End If
GetRootDir = Mid(inputString, t + 1, s - t - 1)
End Function
Затем, в своем коде, укажите ссылку на функцию, подобную этой ...
txtLogFile.Text = GetRootDir(dlgBrowse.FileName)