mikeman118 Posted July 15, 2008 Share Posted July 15, 2008 Hi, As I am copying a directory (DirCopy()), I would like to update my progress bar as to the status of copying. How could I do both of these simultaneously, and accurately? I was thinking of measuring the folder size, and using that to update the control, however those could only occur before or after I have copied the directory. What can I do? Thanks. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 15, 2008 Share Posted July 15, 2008 (edited) Don't use DirCopy(), use something like THISEdit: Or THIS Edited July 15, 2008 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
mikeman118 Posted July 15, 2008 Author Share Posted July 15, 2008 Don't use DirCopy(), use something like THIS Edit: Or THIS Thanks. However, I'm confused at what to do with this. I tried the following: _FileCopy("C:\Installed Apps\Patches\WindowsXP-KB835935-SP2-ENU.exe","C:\temp") Func _FileCopy($fromFile,$tofile) Local $FOF_RESPOND_YES = 16 Local $FOF_SIMPLEPROGRESS = 256 $winShell = ObjCreate("shell.application") $winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES) EndFunc However, nothing I do makes anything happen. Are there any other ways to do this? (I'd like to know in case I try to do something else with progress bars) Link to comment Share on other sites More sharing options...
mikeman118 Posted July 15, 2008 Author Share Posted July 15, 2008 (edited) Ok, never mind, I got the first thing to work. Thanks. Actually, on second thought, (like I said earlier) are there any other ways to do it? The functions is doing weird things to my program, and I'd prefer to use DirCopy(). Is there anything else? Thanks. Edited July 15, 2008 by mikeman118 Link to comment Share on other sites More sharing options...
smashly Posted July 15, 2008 Share Posted July 15, 2008 (edited) You could try and do a recursive filelist to array then step through the file copy setting the progress along the way. Here's a long winded example.expandcollapse popup$Source = @HomeDrive & "\AutoIt Stuff\#AutoIt Projects Misc\" ; directory to copy (2.7GB) $Destination = @HomeDrive & "\Copy Test\" ; copied to here $FLTAR = _FileListToArrayR($Source, "", 0, 1) ProgressOn("Copying...", "Copy Progress") For $i = 1 To $FLTAR[0] If StringInStr(FileGetAttrib($FLTAR[$i]), "D") Then DirCreate($Destination & StringReplace($FLTAR[$i], $Source, "")) Else FileCopy($FLTAR[$i], $Destination & StringReplace($FLTAR[$i], $Source, ""), 9) EndIf ProgressSet((100/$FLTAR[0]) * $i, "Copied: " & StringMid($FLTAR[$i], StringInStr($FLTAR[$i], "\", 0, -1) + 1) & _ @CRLF & "Completed: " & Round((100/$FLTAR[0]) * $i) & "%") Next Func _FileListToArrayR($sPath, $sExFilter = "", $iFlag = 0, $iRecurse = 0, $iDepth = 0) Local $hSearch, $sFile, $sRxpFilter, $asFileList If Not $iDepth Then Global $sHoldFiles = '' If Not FileExists($sPath) Then Return SetError(1, 1, "") If StringRegExp($sExFilter, "[\\/<>:*?]", 0) Then Return SetError(2, 2, "") If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "") If Not ($iRecurse = 0 Or $iRecurse = 1) Then Return SetError(4, 4, "") EndIf If StringRight($sPath, 1) <> "\" Then $sPath &= "\" If $sExFilter = "" Then $sRxpFilter = "." Else $sRxpFilter = "(?i)\.(" & $sExFilter & ")" EndIf $hSearch = FileFindFirstFile($sPath & "*") If $hSearch = -1 Then Return SetError(5, 5, "") While 1 $sFile = FileFindNextFile($hSearch) If @error Then ExitLoop If StringInStr(FileGetAttrib($sPath & $sFile), "D") Then If Not $iRecurse And $iFlag = 1 Then ContinueLoop If $iRecurse Then _FileListToArrayR($sPath & $sFile, $sExFilter, $iFlag, $iRecurse, $iDepth + 1) If $iFlag <> 1 Then $sHoldFiles &= $sPath & $sFile & "|" Else $sHoldFiles &= $sPath & $sFile & "|" EndIf ElseIf StringRegExp($sFile, $sRxpFilter, 0) And $iFlag <> 2 Then $sHoldFiles &= $sPath & $sFile & "|" EndIf WEnd FileClose($hSearch) If Not $iDepth Then $asFileList = StringSplit(StringTrimRight($sHoldFiles, 1), "|") $sHoldFiles = "" Return $asFileList EndIf EndFunc ;==>_FileListToArrayRThere's quite a few good recursive filelist to array functions floating around the forums. Cheers Edited July 15, 2008 by smashly AverageJoe 1 Link to comment Share on other sites More sharing options...
mikeman118 Posted July 15, 2008 Author Share Posted July 15, 2008 Thank you, smashly, that's exactly what I wanted! 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