Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I check if a Directory is empty and Delete it 1

Status
Not open for further replies.

M626

Programmer
Mar 13, 2002
299
0
0
Is there a way I can check if a Directry is empty

"C:\Test\"

If empty then delete "C:\Test\"

Thanks,
 
This should work I think.

Code:
Sub RemoveIfEmpty()
MyFile = Dir("c:\test\*.*")
If Len(MyFile) = 0 Then
    RmDir ("c:\test")
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top