Emiel Wieldraaijer Posted October 17, 2007 Posted October 17, 2007 (edited) Hi All, I want to flush (delete the entire content of) a folder. Let say the Internet Explorer Cache Folder of the Current User some files are in use so the flush command ends.. without erasing everything else which can be deleted i'm using the following code.. Func _Flush($folder) Local $search, $file, $attrib $search = FileFindFirstFile($folder & "\*.*") If $search <> -1 Then While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $attrib = FileGetAttrib($folder & "\" & $file) If StringInStr($attrib, "D") Then DirRemove($folder & "\" & $file, 1) Else FileDelete($folder & "\" & $file) EndIf WEnd EndIf EndFunc is there an error in code .. or isn't it possible Thnx Emiel Edited October 18, 2007 by Emiel Wieldraaijer Best regards,Emiel Wieldraaijer
DW1 Posted October 17, 2007 Posted October 17, 2007 DirRemove:From the help file:Some dir attributes can make the removal impossible.don't know if that helps AutoIt3 Online Help
Emiel Wieldraaijer Posted October 17, 2007 Author Posted October 17, 2007 thnx for the answer .. i am aware of that so i've changed the above question .. a bit .. Emiel Best regards,Emiel Wieldraaijer
Foy Posted October 17, 2007 Posted October 17, 2007 Func _Flush($folder) Local $search, $file, $attrib If $search = FileFindFirstFile($folder & "\*.*") ;Why if? isn't this missing a then too... If $search <> -1 Then While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $attrib = FileGetAttrib($folder & "\" & $file) If StringInStr($attrib, "D") Then DirRemove($folder & "\" & $file, 1) Else FileDelete($folder & "\" & $file) EndIf WEnd EndIfEndFunc
Emiel Wieldraaijer Posted October 18, 2007 Author Posted October 18, 2007 sorry .. didn't belong there.. copy - paste error Emiel Best regards,Emiel Wieldraaijer
Moderators SmOke_N Posted October 18, 2007 Moderators Posted October 18, 2007 Look for _FileListToArrayEx or _FileListToArrayNew in the example forum... there you can recurse or use exclude methods. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Emiel Wieldraaijer Posted October 18, 2007 Author Posted October 18, 2007 Thnx Smoke_N i'll take a look at it .. but i think i will use a simple dos command del *.* /q/s/f and hide it .. one commandline and works very well too bad autoit hasen't got the same function as good old DOS Emiel Best regards,Emiel Wieldraaijer
weaponx Posted October 18, 2007 Posted October 18, 2007 Tell me again why FileDelete ( $folder & "\*.*" ) didn't work???
Emiel Wieldraaijer Posted October 19, 2007 Author Posted October 19, 2007 Tell me again why FileDelete ( $folder & "\*.*" )didn't work???No .. DirRemove and FileDelete will quit when a file is found which cannot be deleted because it's in useDel *.* /Q/S/F will continue so all files which can be deleted will be deleted Best regards,Emiel Wieldraaijer
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now