Question : Delete files in folder and delete subfolder

Access 2000
win 2000 sp4

What I need.

Code to delete all files(all types) in a folder and delete any subfolders

C:\TESTdata


Thanks
fordraiders

Answer : Delete files in folder and delete subfolder

Here ya go...a complete package:

Public Sub DeleteTree(MyPath as string)

DeleteFolder MyPath

End Sub

Public Sub DeleteFolder(MyPath As String)
Dim x as String

x = Dir(MyPath & "\*.*")
If Nz(x, "") <> "" Then Kill MyPath & "\*.*"

x = Dir(MyPath & "\*.*", vbDirectory)
Do Until x = ""
    Debug.Print x
    If ((x <> ".") And (x <> "..")) Then
        DeleteFolder MyPath & "\" & x
        x = Dir(MyPath & "\*.*", vbDirectory)
    Else
        x = Dir
    End If
Loop

RmDir MyPath

End Sub
Random Solutions  
 
programming4us programming4us