xShadowx Posted November 23, 2008 Posted November 23, 2008 Is there a way to have a progress bar for DirRemove and filedelete? I have done: $progressBar = GUICtrlCreateProgress(5,65,190,30) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $Ok GUICtrlSetData($progressBar, 100) If BitAND(GUICtrlRead($1), $GUI_CHECKED) Then DirRemove("folder", 1) Case $GUI_EVENT_CLOSE Exit Case $Exit Exit EndSwitch WEnd But it doesnt work. Any Ideas?
Arikirangi44 Posted November 23, 2008 Posted November 23, 2008 It looks like from your code you are setting the progress bar to 100% if you click Ok.. if you are looping through a list of files to delete you could set the progress bar to a percentage of the total amount of files you are deleting assuming you have a progressbar already assigned in your code with a global variable called $progressBar the code below should work just add the two functions in the _removetestfolders function you can call where $msg = OK you can modify it so it uses and array you create of checked items etc. also you could pass this array to the delete function etc.. hope this helps #include<file.au3> _createtestfolders(@ScriptDir & '\Test_root_folder') _removetestfolders(@ScriptDir & '\Test_root_folder') Func _createtestfolders($path) DirCreate($path) for $i = 1 to 30 DirCreate($path & 'test_folder ' & $i );creates 30 test folders Next ShellExecute($path) ; shows the test folders EndFunc Func _removetestfolders($path) local $array = _FileListToArray( , '*', 2) ; creates a array of folders in the test folder dir local $percentdone = 0 For $i = 1 to ubound($array) - 1 $percentdone = Ceiling(($i / ubound($array) )* 100) ; basic percentage... $i is the count of the items , divided by the total items , multiplied by 100 and rounded to one dp DirRemove ($path & $array[$i],1) GUICtrlSetData($progressBar, $percentdone) Next DirRemove ($path,1) EndFunc
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