Jump to content

Temp delete


au3scr
 Share

Recommended Posts

Perhaps this are files which are still in use of some programs or processes !

It's not recommended to delete them while the process take use of the files.

i.e. my Firewall uses some temporary files in my Temp folder and I don't think that it would be a gain if I force to delete it, isn' t it !?

Maybe the other files without importance you can't delete, are set to read only, so test to set the attributes to writable ...

Run before the DirRemove a FileSetAttrib(.., .., 1) with the '1' parameter at the end.

For subfolders you have to create a loop ...

Greetz

Greenhorn

Edit: Look at here ...

http://www.autoitscript.com/forum/index.ph...temporary+files

; Author:    MadBoy
#Include <File.au3>

;_DirRemoveContents(@UserProfileDir & '\Local Settings\Temporary Internet Files\Content.IE5')
;_DirRemoveContents(@TempDir)

Func _DirRemoveContents($folder)
    Local $list_of_contents, $status
    $list_of_contents = _FileListToArray($folder)
    If IsArray($list_of_contents) Then
        If StringRight($folder, 1) <> "\"  Then $folder = $folder & "\"
        If @error = 1 Then Return 1 ; No Files\Folders Found
        For $a = 1 To $list_of_contents[0]
            FileSetAttrib($folder & "\" & $list_of_contents[$a], "-RASH")
            If StringInStr(FileGetAttrib($folder & $list_of_contents[$a]), "D") Then
                $status = DirRemove($folder & $list_of_contents[$a], 1)
            Else
                $status = FileDelete($folder & $list_of_contents[$a])
            EndIf
        Next
    Else
        Return 2 ; Directory doesn't exists
    EndIf
EndFunc   ;==>_DirRemoveContents

Edited by Greenhorn
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...