试试:
'判断目录是否存在,存在就删除目录中的所有文件及目录本身
If Dir(thepath, vbDirectory) <> "" Then
If Dir(thepath & "\*.*") <> "" Then
Kill thepath & "\*.*" '没有子目录
End If
End If
If Dir(thepath, vbDirectory) <> "" Then
If Dir(thepath & "\*.*") = "" Then
RmDir thepath '文件删除完成后,再删除文件夹
End If
End If