directory: Test whether a path is a directory or a filename

G

Guest

Hello,
I'm trying to copy files with "Filecopy A B".
If my source-path (A) is a directory and not a filename I get an error.
How can I test whether A is a directory or a filename??

Tanks a lot,
Mibi
 
B

Bob Phillips

Mibi,

Here is na function, but note the directory needs to be appended with "\",
so I did it in code

'-----------------------------------------------------------------
Function IsFolder(Folder) As Boolean
'-----------------------------------------------------------------
Dim sFolder
IsFolder = False
On Error GoTo if_exit
sFolder = Dir(Folder & "\", vbDirectory)
If sFolder <> "" Then
Select Case True
Case sFolder = ".": IsFolder = True
Case sFolder = "..": IsFolder = True
Case GetAttr(sFolder And vbDirectory) = vbDirectory: IsFolder =
True
End Select
End If
if_exit:
End Function


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top