RecycleFile (Windows)
Posted: Sat Aug 17, 2002 5:40 am
Restored from previous forum. Originally posted by PB.
UPDATE: See corrected code further down (dated Mon Feb 11, 2008).
The example in this first particular post is faulty and not 100% reliable.
This procedure lets you "delete" files by sending them to the Recycle Bin (also
known as the Trash Can) instead of permanently deleting them as DeleteFile does.
Note that there is a bit of a delay after calling this procedure to the time the
file(s) is recycled... I don't know if this can be sped up, but I doubt it. You
can use this with wildcards (*?) too, just like DeleteFile does. Enjoy!
; RecycleFile by PB -- do what you want with it.
; Usage: RecycleFile(file$)
; Same as DeleteFile() except files go to the bin.
;
Procedure RecycleFile(file$)
SHFileOp.SHFILEOPSTRUCT
SHFileOp\pFrom=@file$
SHFileOp\wFunc=#FO_DELETE
SHFileOp\fFlags=#FOF_ALLOWUNDO
SHFileOperation_(SHFileOp)
EndProcedure
PB - Registered PureBasic Coder
Edited by - PB on 17 August 2002 07:01:53
UPDATE: See corrected code further down (dated Mon Feb 11, 2008).
The example in this first particular post is faulty and not 100% reliable.
This procedure lets you "delete" files by sending them to the Recycle Bin (also
known as the Trash Can) instead of permanently deleting them as DeleteFile does.
Note that there is a bit of a delay after calling this procedure to the time the
file(s) is recycled... I don't know if this can be sped up, but I doubt it. You
can use this with wildcards (*?) too, just like DeleteFile does. Enjoy!
; RecycleFile by PB -- do what you want with it.

; Usage: RecycleFile(file$)
; Same as DeleteFile() except files go to the bin.
;
Procedure RecycleFile(file$)
SHFileOp.SHFILEOPSTRUCT
SHFileOp\pFrom=@file$
SHFileOp\wFunc=#FO_DELETE
SHFileOp\fFlags=#FOF_ALLOWUNDO
SHFileOperation_(SHFileOp)
EndProcedure
PB - Registered PureBasic Coder
Edited by - PB on 17 August 2002 07:01:53