rudi Posted February 24, 2010 Share Posted February 24, 2010 Hi.I have to copy a bunch of quite large files for my users to the server for backup purposes.I found quite a lot of threads on "filecopy with progress", they didn't really help to solve what I need:All files to be copied are hold in an array. Progress1 displays the percentage of "files copied". As the files are large, I want a progress2, displaying the percentage of the CURRENT file's copy process.This 2nd task is where I fail. Looks like I need to copy the file in chunks, so that I can update the progress bar after each portion copied. But this fails, because the FileRead() doesn't seem to get further data somewhere within the copy process.The code below just covers the "progress1", the other lines were kicked to make it shorter.expandcollapse popup; autoit 3.3.4.0 ; set file names $file = "w2ksp4de.iso" ; file size: 393.170.944 bytes $in = "C:\install\" & $file $out = "C:\temp2\" & $file ; open files $h_in = FileOpen($in, 0 + 16) ; using 0 fails as well $h_out = FileOpen($out, 2 + 8 + 16) ; using 2 + 8 fails as well $w = 400 $h = 80 $MyGui = GUICreate("File Copy Progress", $w, $h) $Prgr = GUICtrlCreateProgress(8, 8, $w - 16, 20) $Lbl = GUICtrlCreateLabel("", 8, 35, $w - 16, 40) GUISetState(@SW_SHOW) AdlibRegister("Update_it", 1000) $C_Size = 4 * 1024 ; default NTFS cluster size. Other sizes fail at different positions. $C_Count = 0 While 1 $C_Count += 1 $Chunck = FileRead($h_in, $C_Size) If @error == -1 Then ConsoleWrite("Chunk # " & $C_Count & ", Extended=" & @extended & @CRLF) ExitLoop EndIf ConsoleWrite(@extended & @CRLF) If Not FileWrite($h_out, @extended) Then MsgBox(0, "Error", "Copying *NOT*`completed successfully!") EndIf WEnd FileClose($h_out) FileClose($h_in) AdlibUnRegister("update_it") MsgBox(0, "info", "done.") Func Update_it() $Full = FileGetSize($in) $Done = FileGetSize($out) $Prozent = Round($Done / $Full * 100, 1) ConsoleWrite($Prozent & ", " & $Done & ", " & $Full & @CRLF) GUICtrlSetData($Prgr, $Prozent) GUICtrlSetData($Lbl, $Prozent & "% copied." & @LF & "Org: " & $Full & @LF & "Done: " & $Done) EndFunc ;==>UpdatenWhat do I miss? Beside the failure problem, the copy process I coded is incredibly slow ...Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
thexshadow Posted February 26, 2010 Share Posted February 26, 2010 Check this out. http://www.autoitscript.com/forum/index.php?showtopic=104509&st=0&p=739268&hl=file%20progress%20bar&fromsearch=1&#entry739268 Link to comment Share on other sites More sharing options...
rudi Posted February 26, 2010 Author Share Posted February 26, 2010 Hi.http://www.autoitscript.com/forum/index.php?showtopic=104509&st=0&p=739268&hl=file%20progress%20bar&fromsearch=1&#entry739268Thanks, I've seen that one.But I can't see where it should describe to manage a progress bar for the CURRENT RUNNING FILECOPY(). (2 progress bars, one = overall progress, other one cur.dir?)Seems I'm blind?? Who opens my eyes, pls?Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
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