DeleteAllFilesInFolder

DeleteAllFilesInFolder

Public Sub DeleteAllFilesInFolder( _
    strPathToFolder As String _
)
    Dim _
        fs As Object, _
        fldr As Object, _
        f As Object
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set fldr = fs.GetFolder(strPathToFolder)
    For Each f In fldr.Files
        Application.StatusBar = _
            "Deleting file " & _
            f.Name & _
            " from folder " & _
            strPathToFolder
        DoEvents
        f.Delete True
    Next
    Set f = Nothing
    Set fldr = Nothing
    Set fs = Nothing
    Application.StatusBar = False
End Sub

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *