This function returns the full directory, when passed the full filepath.
The function searches for the leading backslash to determine the end of the directory. Add
the following code to a FileHandling.bas standard module to compile a File Utility
function set:
Function GetDirName(ScanString As String) As String
'*************************************************************
'<DESC> Retrieves a directory path from full path
' (ie filepath & filename)</DESC>
'<RETURN> Boolean:
' <LI> Dir Path as String
' </RETURN>
'<ACCESS> Public
'<ARGS> FullPath: Full Filepath incl. Filename
' </ARGS>
'<USAGE> DirPath$ = ("c:/winnt/winhlp32.exe")
' </USAGE>
'*************************************************************
Dim intPos As Integer
Dim intPosSave As Integer
intPos = 1
Do
intPos = InStr(intPos, ScanString, "\")
If intPos = 0 Then
Exit Do
Else
intPos = intPos + 1
intPosSave = intPos - 1
End If
Loop
GetDirName = Left$(ScanString, intPosSave)
End Function
|