Jump to content
Sign in to follow this  

Progress bar

Recommended Posts


Is there a way to have a progress bar for DirRemove and filedelete?

I have done:

$progressBar = GUICtrlCreateProgress(5,65,190,30)

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
        Case $Exit  

But it doesnt work. Any Ideas?

Share this post

Link to post
Share on other sites

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


_createtestfolders(@ScriptDir & '\Test_root_folder')
_removetestfolders(@ScriptDir & '\Test_root_folder')

Func _createtestfolders($path)
for $i = 1 to 30
    DirCreate($path & 'test_folder ' & $i  );creates 30 test folders
ShellExecute($path) ; shows the  test folders 

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)
DirRemove ($path,1)

Share this post

Link to post
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
Sign in to follow this