Jump to content

Realtime File Progress bar w/ LargeFileCopy


Cravin
 Share

Go to solution Solved by Cravin,

Recommended Posts

So, for the life of me, even after spending a couple of hours of google and forum searches, I can't figure out how to update a progress bar in real time with the status of a file transfer using _LargeFileCopy.  Any suggestions/helpful hints would be greatly appreciated! 

EDIT: The issue is that the progress bar stays at 0%, not updating as the file is transferred.

The block of code I'm currently attempting which is not working is below:

For $i = 0 To UBound($aFinal) - 1
        $iFilesTransfered += 1
        $CopyTo = StringReplace($aFinal[$i], $DataTabTargetNameInput, "C:\")
        GUICtrlSetData($CurrentFile, StringReplace($aFinal[$i], $DataTabTargetNameInput, "C:"))
        $SrcFileSize = FileGetSize($aFinal[$i])

        _LargeFileCopy($aFinal[$i], $CopyTo, BitOR(1, 2, 64, 128, 256, 512))

        While 1
            $DestFileSize = FileGetSize($CopyTo)
            If $DestFileSize = $SrcFileSize Then
                ExitLoop
            Else
                $CurrentFilePctCopied = Round($DestFileSize / $SrcFileSize * 100, 1)
                _ProgressSet($Progress1, $CurrentFilePctCopied)
                _ProgressSetText($Progress1, $CurrentFilePctCopied)
                Sleep(250)
            EndIf
        WEnd

        If $iFilesTransfered = $tUniqueFiles Then
            GUICtrlSetData($CurrentFile, "Transfer finished!")
            $iFilesTransfered = 0
        EndIf
    Next
Edited by Cravin
Link to comment
Share on other sites

Maybe >this will help you.

Yashied, I considered using that Copy UDF you wrote but since my array returns files only and not folders, the LargeFileCopy udf I thought was easier to implement because it creates the dir structure without having to go back through and add that functionality in... unless I missed something about _Copy_CopyFile.. :)

Link to comment
Share on other sites

_Copy_CopyDir()?

Couldn't use CopyDir because it defeats the purpose of my script which is to be able to exclude multiple files/directories, so in order to form my array, I pass everything through M23's RecFileListToArray UDF and then combine those arrays into a single one, in this case named $aFinal and then call LargeFileCopy on each file from there...

Link to comment
Share on other sites

Can you post a reproducer script that demonstrates what it is you're doing and how? Right now we have several functions that we can't know what they're doing so it's practically impossible to know where you went wrong.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Can you post a reproducer script that demonstrates what it is you're doing and how? Right now we have several functions that we can't know what they're doing so it's practically impossible to know where you went wrong.

Sure, give me a few moments to strip some things out, thanks!

Link to comment
Share on other sites

Attached is a copy of my script and all the includes required.  It's fairly messy still so bear with me... and any thoughts in making it more efficient are welcome too. :)

Note: To use, run the script named "FileCopyTest.au3", then enter the name of your local computer account, and in the UNC path section, enter your computer name, ie computerc$ - then select "Selective Copy" and check "C: Variances" and then Begin Transfer...  All the selective options are implemented.. but you'll see during the progress, that the top progress bar stays at 0%.

EDIT: Fixed the attachment so that it writes files to C:test

Edited by Cravin
Link to comment
Share on other sites

Looking >HERE seems to be a possibility... seems LargeFileCopy has some form of a built in capacity to call a function that will check file size, but how could I implement this into my current script so that it properly updates $Progress1?

Sorry for such newbie questions, I'm trying, really. :D

Link to comment
Share on other sites

I think the problem lies somewhere within the While loop. Take it out of the while loop, and you get progress (not the intended progress though). Take a look again at the logic of the loop.

Yeah, I do believe you are correct.. I'm thinking perhaps Adlibregister may need to come into play some how here which I have no experience with. Thanks for the thoughts!

Link to comment
Share on other sites

  • Solution

I was able to get this figured out.. Basically, I created a function that did this:

_LargeFileCopy($aFinal[$i], $CopyTo, BitOR(1, 2, 64, 128, 256, 512), 2097152, "", "_UpdateProgress")

Func _UpdateProgress($iTotal, $iSize, $Percent)
    $Percent = Round(($iTotal / $iSize) * 100, 1)
    _ProgressSet($Progress1, $Percent)
    _ProgressSetText($Progress1, $Percent)
EndFunc   ;==>_UpdateProgress
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...