#include-once #include #Region Globals_ExtMngr Global $__aOnExit[0] #EndRegion Func _Clear_Temp_Files() _On_Exit(Default, False) EndFunc Func _On_Exit($fFileFolder = Default, $bExit = True) If $fFileFolder == Default Then For $l = 0 To UBound($__aOnExit) - 1 If StringInStr(FileGetAttrib($__aOnExit[$l]),"D") Then DirRemove($__aOnExit[$l], 1) Else FileDelete($__aOnExit[$l]) EndIf Next If $bExit Then Exit(0) EndIf EndIf _ArrayAdd($__aOnExit, $fFileFolder) If UBound($__aOnExit) > 1000 Then For $l = UBound($__aOnExit) - 1 To 0 Step -1 If Not FileExists($__aOnExit[$l]) Then _ArrayDelete($__aOnExit, $l) EndIf Next EndIf EndFunc