Discussion Locked

VB6 - Testing if a directory is empty

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

folderExists and fileExists don't seem to accept wildcards. How can you check if a particular directory is empty?

Thanks
Andrew

7 replies

by tclere

If Dir("C:\Temp\*.*") = "" Then
'folder is empty
Else
'folder is not empty
End If

by ad

Only works if directory doesn't contain files - if directory contains just subdirectories then it will mis-report.

But - I didn't know about the 'Dir' command: lloking it up in the MSDN help does give some example code which does the job (andwhich can be modified to pick up directories and/or files.

by lo

Hi - #1 works fine.

You will also get a folder is empty if the directory path doesn't exist. Lo

This discussion is closed to new replies.