UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> IsFolderEmpty    

' IsFolderEmpty
' http://www.utteraccess.com/wiki/index.php/IsFolderEmpty
' Code courtesy of UtterAccess Wiki
' Licensed under Creative Commons License
' http://creativecommons.org/licenses/by-sa/3.0/
' You are free to use this code in any application,
' provided this notice is left unchanged.
' rev     date                  brief descripton
' 1.0     2013-06-29            Checks if a folder is empty                    

Public Function IsFolderEmpty(strFolderPath As String) As Boolean

Dim fso As Object
Dim fldr As Object
Dim boolEmpty As Boolean

Set fso = CreateObject("Scripting.FileSystemObject")

boolEmpty = False

If fso.FolderExists(strFolderPath) Then
   Set fldr = fso.GetFolder(strFolderPath)

   If fldr.Files.Count + fldr.SubFolders.Count = 0 Then
       boolEmpty = True
   End If

End If

IsFolderEmpty = boolEmpty

Set fldr = Nothing
Set fso = Nothing

End Function

Creative Commons License
IsFolderEmpty by UtterAccess Wiki is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Editing and revision of the content is freely encouraged; for details, see Expected Usage.

Edit Discussion
Custom Search

Thank you for your support!
This page has been accessed 6,182 times.  This page was last modified 20:37, 30 June 2013 by TheDBguy.   Disclaimers