Working with the Windows command line doesn't have to be risky! Delete multiple files to the Recycle Bin:
recycle file1 file2 supports-wildcards\*.tmp
Download the main executable; put it in %PATH%; 'nuff said...
v0.2 - Proper exit codes when encountering error. If multiple files are given, the exit code for the last argument will be returned.
- 0: Success
- 1: Miscellaneous errors (such as permission)
- 2: File/pattern not found
Visual Basic's FileSystem
object has the DeleteFile()
and DeleteDirectory()
methods which both support an argument to specify deleting to the Recycle Bin. Luckily using .NET, we rolled this with C# alright.
Support for programmatically deleting files to the Recycle Bin is surprisingly rare. SHFileOperation
used to be the only way to do it, but that Win32 API call is quite old and Microsoft said the interface has been replaced by IFileOperation
. Furthermore, I found my homegrown program (using SHFileOperation
) stopped working after I migrated to Windows 7 x64.
The Windows API is such a pile of stuffs. I don't know if I'm using the new endorsed IFileOperation
or whatnot, but this one here using Visual Basic's FileSystem
seems to work alright, so I'll just leave it at that :)