cracksys Posted May 9, 2009 Posted May 9, 2009 (edited) 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 May 9, 2009 by cracksys
Authenticity Posted May 9, 2009 Posted May 9, 2009 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Ò
cracksys Posted May 9, 2009 Author Posted May 9, 2009 (edited) 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 May 9, 2009 by cracksys
Authenticity Posted May 9, 2009 Posted May 9, 2009 (edited) ... 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 May 9, 2009 by Authenticity
cracksys Posted May 10, 2009 Author Posted May 10, 2009 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.
Authenticity Posted May 10, 2009 Posted May 10, 2009 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.
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