Jump to content
Sign in to follow this  
MadBoy

Copy dir with progress - need some help

Recommended Posts

MadBoy

Hello,

I've got this problem. I've searched whole forum for copy dir with progress and seen a lot of solutions that were kinda not what i realy wanted so i wrote my own one. What it does it copies dir with xcopy and compares destination and source every number of seconds. It doesn't have to perfect because i'm using it to send files between countries so the speed is slow but the big problem of it is that it works perfect on small files that go fast and it updates progress nicely on GUI_LABEL. But when there is a big file that is 200mb of size and when it starts getting copied Dirsize for destination and source is in 1-2 second the same (because windows reports the file has already 200mb, as in reserving the space or so). xcopy process is still going but my script reports 100% done :/ I've implemented ProcessWaitClose to not go to copying to another server before the one is done because i don't want 12 xcopy's running and network to die. So my question is, can this be done better but keeping it the way it is ? I wouldn't like to start the windows copying file window as it is visible (unless it can be hidden? but then how to report progress of it to $GUI_LABEL). I've seen other solutions like i said before and not realy sure if they suffer the same problem (maybe except the Windows one). Hope to get some advice from You :shocked:

Func _CopyDirectoryWithProgress($source, $destination, $update_label)
 Local $origdirsize, $copydirsize, $copy
 $origdirsize = DirGetSize($source)
 $copydirsize = DirGetSize($destination)
 If $origdirsize <> $copydirsize Then
  $copy = Run(@ComSpec & ' /c xcopy "' & $source & '" "' & $destination & '" /E /I /Y', "", @SW_HIDE)
  While 1
   Sleep(2000)
   $origdirsize = DirGetSize($source)
   $copydirsize = DirGetSize($destination)
   $percent = Round($copydirsize / $origdirsize * 100, 2)
   ;GUICtrlSetData($update_label, Round($copydirsize/1000,0) & " of " & Round($origdirsize/1000,0) & "KB (" & Round($copydirsize / 1000000, 2) & "/" & Round($origdirsize / 1000000, 2) & "MB) " & $percent & "%")
   GUICtrlSetData($update_label, Round($copydirsize / 1000, 0) & " of " & Round($origdirsize / 1000, 0) & "KB (" & $percent & "%)")
   If $origdirsize = $copydirsize Then
    GUICtrlSetData($update_label, "Copying still...")
    ProcessWaitClose($copy)
    GUICtrlSetData($update_label, "Finally done!")
    ExitLoop
   EndIf
  WEnd
 Else
  $percent = Round($copydirsize / $origdirsize * 100, 2)
  GUICtrlSetData($update_label, Round($copydirsize / 1000, 0) & "KB of " & Round($origdirsize / 1000, 0) & "KB (" & $percent & "%)")
  ;"Idling...123233333334576890"
  ;GUICtrlSetData($update_label, Round($copydirsize/1000,0) & "KB of " & Round($origdirsize/1000,0) & "KB (" & Round($copydirsize / 1000000, 2) & "/" & Round($origdirsize / 1000000, 2) & "MB) " & $percent & "%")
 EndIf
EndFunc   ;==>_CopyDirectoryWithProgress

Cheers :(


My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites
MadBoy

That's the thing i don't want :) I seen that but i don't want Explorer window to show up. I want it to be purely integrated with my program GUI so it looks professional :D


My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites
Martinibianco

Hi MadBoy..

i have the same problem... have you find a solution?

My progressbar reach 100% with 1 file of 1Gb in 1 second :)

Share this post


Link to post
Share on other sites
darbid

Hi MadBoy..

i have the same problem... have you find a solution?

My progressbar reach 100% with 1 file of 1Gb in 1 second :P

I am very interested to know if this topic has a final result on the basis of the initial question.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.