Board index » Visual Studio » Empty Recycle Bin
|
drbob2000
|
Empty Recycle Bin
Visual Studio1
I can display the files in the Recycle Bin for the user but would like to empty it. The code below "reports file not found" using the deletefile method. Is there a better way? ---------------- Const RECYCLE_BIN = &Ha& Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(RECYCLE_BIN) Set objFolderItem = objFolder.Self Set objFSO = CreateObject("Scripting.FileSystemObject") WScript.Echo "Recycle Bin Location: " & objFolderItem.Path WScript.Echo "Files in Recycle Bin" WScript.Echo "--------------------" Set colItems = objFolder.Items For Each objItem in colItems Wscript.Echo objItem.Name Next WScript.Echo VbCrLf & "Deleting Files in Recycle Bin" For Each objItem in colItems objFSO.DeleteFile(objFolderItem.Path & "\" & objItem.Name) Next WScript.Echo VbCrLf & "Files NOW in Recycle Bin" WScript.Echo "------------------------" For Each objItem in colItems Wscript.Echo objItem.Name Next ---------------- - |
