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

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top