Link to home
Start Free TrialLog in
Avatar of Hiken
HikenFlag for United States of America

asked on

Access module problem killing files

What I'm trying to do is delete all files in a folder.  This code works except it locks up on a file called thumb.db.  Everything else deletes.  I don't see thumbs.db in the folder any ideas on how to fix?

Dim aflle As File
Dim afolder As Folder

Set afolder = fs.GetFolder(DLookup("CdfExportLocation", "tSetDefaults"))
       
   For Each afile In afolder.Files
     
        If IsNull(afolder) Then
   
   Else
   
        Kill (aFile)

End If
  Next
ASKER CERTIFIED SOLUTION
Avatar of ErezMor
ErezMor
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rey Obrero (Capricorn1)
here is a dirty fix


On error resume next    'Add this line

Dim aflle As File
Dim afolder As Folder

Set afolder = fs.GetFolder(DLookup("CdfExportLocation", "tSetDefaults"))
       
   For Each afile In afolder.Files
     
        If IsNull(afolder) Then
   
   Else
   
        Kill (aFile)

End If
  Next
Avatar of Hiken

ASKER

Thanks  that got it
cheers mate!