Archive: How can i check, if a folder is emtpy?


How can i check, if a folder is emtpy?
Hi,
how can i detect subdirectories in a folder, or it is empty?

Thanks


Function IsFolderEmpty
Exch $R0
Push $R1
ClearErrors
FindFirst $R1 $R0 $R0\*.*
IfErrors +7
StrCmp $R0 . +4
StrCmp $R0 .. +3
StrCpy $R0 0
Goto +4
FindNext $R1 $R0
Goto -6
StrCpy $R0 1
FindClose $R1
Pop $R1
Exch $R0
FunctionEnd


Push $INSTDIR\somefolder
Call IsFolderEmpty
Pop $R0

$R0 == 1 if empty; 0 otherwise. Note this includes files as well as folders.

Stu

Thanks!!!!!!!