Tjena :)
Testa detta. Paramtern i funktionsanropet specificerar vilken katalog som du vill ta bort alla filer i.
Google Says.. skrev:
Public Function DeleteAllFiles(ByVal FolderSpec As String) _ As Boolean 'Deletes all files in folder specified 'by parameter FolderSpec. Does not delete 'subfolders or files within subfolders 'Returns True if sucessful, false otherwise 'Requires a reference the Microsoft Scripting Runtime 'EXAMPLE: DeleteAllFiles "C:\Test" Dim oFs As New FileSystemObject Dim oFolder As Folder Dim oFile As File If oFs.FolderExists(FolderSpec) Then Set oFolder = oFs.GetFolder(FolderSpec) On Error Resume Next For Each oFile In oFolder.Files oFile.Delete True 'setting force to true 'deletes read-only file Next DeleteAllFiles = oFolder.Files.Count = 0 End If End Function
