Ich habe im Forum eine Routine gefunden, um Dateien in den Papierkorb zu verschieben:
Code: Alles auswählen
Procedure SK_RecycleFile(file$, ask.b=0, noerror.b=0, progress.b=1) ; PB3+4
Define.l result
; #define FOF_SILENT 0x0004 // keine Angabe über
; // Fortschritt
; #define FOF_NOERRORUI 0x0400 // keine Fehler-UI
; #define FOF_ALLOWUNDO 0x0040 // für Papierkorb
; // erforderlich!
; #define FOF_NOCONFIRMATION 0x0010 // keine Rückfrage
SHFileOp.SHFILEOPSTRUCT
SHFileOp\pFrom = @file$
SHFileOp\wFunc = #FO_DELETE
SHFileOp\fFlags = #FOF_ALLOWUNDO
If ask=0
SHFileOp\fFlags | #FOF_NOCONFIRMATION
EndIf
If noerror=1
SHFileOp\fFlags | $0400
EndIf
If progress=0
SHFileOp\fFlags | #FOF_SILENT
EndIf
result = SHFileOperation_(SHFileOp)
CompilerIf #PB_Compiler_Debugger
Debug "SK_Recyclefile: "+file$
Debug "SK_Recyclefile: Result = "+Str(result)
CompilerEndIf
; Liefert 0 (NULL) zurück wenn alles ok
; 1026 : Datei nicht vorhanden
If result = 0
result = #True
EndIf
ProcedureReturn result
EndProcedure
Code: Alles auswählen
NewList ReadDirInfo$()
Procedure.l SK_ReadDirFast(Path.s="", SubDirs.b=1) ; PB4
Shared ReadDirInfo$()
Protected Dir.l
If Right(Path,1)<>"\" : Path+"\" : EndIf
Dir.l = ExamineDirectory(#PB_Any, Path, "")
If IsDirectory(Dir)
While NextDirectoryEntry(Dir)
name$ = DirectoryEntryName(Dir)
If DirectoryEntryType(Dir) = #PB_DirectoryEntry_File
AddElement(ReadDirInfo$())
ReadDirInfo$() = Path + name$
Debug "FILE: "+name$
ElseIf DirectoryEntryType(Dir) = #PB_DirectoryEntry_Directory And SubDirs; Dir
Debug "DIR: "+name$
If name$<>"." And name$<>".."
SK_ReadDirFast(Path + name$, SubDirs)
EndIf
EndIf
Wend
FinishDirectory(Dir)
Else
ProcedureReturn #False
EndIf
ProcedureReturn #True
EndProcedure
Versuche ich nun über den Code:
Code: Alles auswählen
Debug sk_readdirfast("D:\Tests\Delete\")
ForEach readdirinfo$()
Debug SK_RecycleFile(readdirinfo$())
Next
Hat jemand eine Idee?
