Dim Mdir As String = "C:\Users\xf35564\AppData\Roaming\Skype\programma121" If Dir("C:\Users\xf35564\AppData\Roaming\Skype\programma121", FileAttribute.Directory) <> "" Then 'Delete all files and subfolders 'Be sure that no file is open in the folder Dim FSO As Object Dim MyPath As String FSO = CreateObject("scripting.filesystemobject") MyPath = Mdir '"C:\Users\Ron\Test" '<< Change If FSO.FolderExists(MyPath) = False Then MsgBox(MyPath & " doesn't exist") Exit Sub End If On Error Resume Next 'Delete files FSO.deletefile(MyPath & "\*.*", True) 'Delete subfolders Do If Dir(Mdir, FileAttribute.Directory) <> "" Then FSO.deletefolder(MyPath & "\*.*", True) FSO.deletefolder(MyPath, True) On Error GoTo 0 Else Exit Do End If Loop End If |