Code: Select all
Global NewList sgFilesToTrash.s()
AddElement(sgFilesToTrash())
sgFilesToTrash() = "C:\MyTemp\Folder03_EMT"
Procedure ToRecycleBin(*ptrFile)
;--------------------------------
sTemp.s = PeekS(*ptrFile,-1,#PB_UTF8)
Debug "ToRecycleBin(*ptrFile)-->" + sTemp + "<--"
Protected SHFileOp.SHFILEOPSTRUCT
SHFileOp\pFrom = *ptrFile
SHFileOp\pTo = #Null
SHFileOp\wFunc = #FO_DELETE
SHFileOp\fFlags = #FOF_ALLOWUNDO | #FOF_NOCONFIRMATION ;| #FOF_SILENT
If SHFileOperation_(@SHFileOp) = 0
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
SelectElement(sgFilesToTrash(),0)
*ptrFile = AllocateMemory(StringByteLength(sgFilesToTrash()) + (2 * SizeOf(Character)))
PokeS(*ptrFile,sgFilesToTrash(),-1,#PB_UTF8)
Debug "sgFilesToTrash()-->" + sgFilesToTrash() + "<--" ;C:\MyTemp\Folder03_EMT
ToRecycleBin(*ptrFile)Error returned: Cannot delete file: Cannot read from the source file or disk.
It's obviously possible to delete folders, so what could be wrong?

