- Sub ClrRecycleBin() '清空回收站
- On Error Resume Next
- Dim oShell, oSHFolder, objFSO, oSHFItem, FilePath
-
- Set oShell = CreateObject("Shell.Application")
- Set oSHFolder = oShell.Namespace(&Ha&)
- Set objFSO = CreateObject("Scripting.FileSystemobject")
-
- FOR each oSHFItem IN oSHFolder.Items
- IF (oSHFItem.type = "File Folder") THEN '删除文件夹
- FilePath = oSHFItem.Path
- objFSO.DeleteFolder FilePath,True
- ELSE '删除文件
- FilePath = oSHFItem.Path
- objFSO.DeleteFile FilePath,True
- End IF
- NEXT
-
- Set objFSO = Nothing
- Set oshell = Nothing
- Set oSHFolder = Nothing
- END Sub
复制代码
|