I want to remove all xml files in a temporary directory before proceeding with my macro.
What is the preferred method?
Kill is a one liner but will throw a run time error if there are no xml files in the directory.
Code:
Kill c:\tmp\*.xml
FSO will require a runtime dependency (although I already have Scripting Runtime for Dictionary)
Code:
Public Sub DeleteFiles(strFolderName As String, strType As String)
    Dim fso As Scripting.FileSystemObject
    Dim fsoDir As Scripting.Folder
    Dim fsoFile As Scripting.File

    Set fso = New Scripting.FileSystemObject
    Set fsoDir = fso.GetFolder(strFolderName)


    For Each fsoFile In fsoDir.Files
        If fsoFile.Type = strType Then
            fsoFile.Delete
        End If
    Next fsoFile

End Sub
Not familiar with the API to delete all files of a certain type in a directory.