Find the directory part (minus the filename) of a full path in access 97
I always used the FileSystemObject
for this sort of thing. Here's a little wrapper function I used. Be sure to reference the Microsoft Scripting Runtime
.
Function StripFilename(sPathFile As String) As String
'given a full path and file, strip the filename off the end and return the path
Dim filesystem As New FileSystemObject
StripFilename = filesystem.GetParentFolderName(sPathFile) & "\"
Exit Function
End Function
You can do something simple like: Left(path, InStrRev(path, "\"))
Example:
Function GetDirectory(path)
GetDirectory = Left(path, InStrRev(path, Application.PathSeparator))
End Function