Jump to content

Progress Bar with no progress


Recommended Posts

CODE
$dirsize_before = DirGetSize("E:\Briefcase\", 1)

$dirsize_cur = $dirsize_before

$percent = 100

ProgressOn("Briefcase Backup!", "", "Removing Briefcase directory ...", -1, -1, 1)

DirRemove("E:\Briefcase\", 1)

While $percent > 0

$dirsize_cur = DirGetSize("E:\Briefcase\", 1)

$percent = ($dirsize_cur *100) / $dirsize_before

ProgressSet( $percent, "Removing Briefcase directory ... " & $dirsize_before & "%", "")

WEnd

Progress bar will appear before folder romoval but its stayed there forever without any progress shown. Even after folder has been completely removed.

Edited by cracksys
Link to comment
Share on other sites

Read again the function definition of DirGetSize(). It returns an array type if the second parameter is 1 so something like:

$dirsize_cur = DirGetSize("E:\Briefcase\", 1)
$percent = ($dirsize_cur *100) / $dirsize_beforeoÝ÷ Ú+½©nj׶®¶­sbb33c¶F'6¦Uö7W"ÒF$vWE6¦RgV÷C´S¢b3#´'&Vf66Rb3#²gV÷C²Â¢b33c·W&6VçBÒ£òb33c¶F'6¦Uö&Vf÷&R²÷6öÖWFærÒ
Link to comment
Share on other sites

Silly me. So, it should've been like this :

$percent = ($dirsize_cur[0] *100) / $dirsize_before[0]

Correct? -- I'm sorry, at office right now so no testing.

Edited by cracksys
Link to comment
Share on other sites

:) ... on success. Always check if a variable is of array type before accessing it's subscript members, so you can do yourself a favor and use IsArray, exactly as in the function example script in the help file. Edited by Authenticity
Link to comment
Share on other sites

Thanks. I tried but I failed.

$dirsize_before = DirGetSize("E:\Briefcase\", 1)
            $dirsize_cur = DirGetSize("E:\Briefcase\", 1)
            ProgressOn("Briefcase Backup!", "", "Removing Briefcase directory ...", -1, -1, 1)
            If IsArray($dirsize_before) Then
                DirRemove("E:\Briefcase\", 1)
                Do
                    $percent = $dirsize_cur[0] * 100 / $dirsize_before[0]
                    ProgressSet( $dirsize_cur[0] * 100 / $dirsize_before[0], "Removing Briefcase directory ... " & $percent, "")
                Until $dirsize_cur[1] = 0
                ProgressOff()
            EndIf

Folder will be removed but progress bar start updating after that and its kept looping.

Link to comment
Share on other sites

I guess that it's because you're not updating the variable. If $dirsize_cur[1] is 65 files when entering the loop, it'll be so forever because nothing is updating the variable. You need to call DirGetSize() also while in the loop, don't know if it'll return something because technically you've removed this directory.

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...