|
看看下面的代码错在哪里了:
$Source = "F:\水木方XP3英文版.iso" ; directory to copy (2.7GB)
$Destination = "e:\" ; copied to here
$FLTAR = _FileListToArrayR($Source, "",0,0, 1)
MsgBox(0,"",$FLTAR)
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 ;==>_FileListToArrayR |
|