这一个到不错,但是只能复制文件夹,不能单独复制文件,能否修改下,让它支持文件 复制。
Func _COPY()
ProgressCopy("E:\MHT_YS_IPXE\wim\soft", "C:\Windows\TEMP",1)
EndFunc
Func ProgressCopy($current, $destination, $UseMultiColour=0, $attrib = "-R", $overwrite = 1 ,$Run1 = 0 )
If $Run1 = 0 Then
Global $OverallQty, $Overall, $source, $overallpercent, $Pro0Text, $Pro, $ProText, $Pro2, $Pro1Text, $LocalPercent
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
If not FileExists ($Destination) then DirCreate ($Destination); This is why it was failing, the dir did not exist
$source = $current
If StringRight($current, 1) = '\' Then $current = StringTrimRight($current, 1)
If StringRight($destination, 1) <> '\' Then $destination = $destination & "\"
$tosearch = $current
$Overall = DirGetSize($tosearch, 1)
$OverallQty = $Overall[1]
$Run1 = 1
EndIf
$Size = DirGetSize($current, 3)
$Qty = $Size[1]
Local $search = FileFindFirstFile($current & "\*.*")
While 1
Dim $file = FileFindNextFile($search)
If @error Or StringLen($file) < 1 Then ExitLoop
If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then
$Qty -= 1
$LocalPercent = 100 - (($Qty / $Size[1]) * 100)
$OverallQty -= 1
$overallpercent = 100 - (($OverallQty / $Overall[1]) * 100)
GUICtrlSetData($Pro0Text, "已完成:"& Int($overallpercent) & "%")
GUICtrlSetData($Pro, $overallpercent)
GUICtrlSetData($Pro2, $LocalPercent)
GUICtrlSetData($Pro1Text, "正在拷贝: " & $file &"文件" )
If $useMultiColour then
GUICtrlSetColor($Pro2, _ChangeColour($LocalPercent))
GUICtrlSetColor($Pro, _ChangeColour($OverallPercent))
EndIf
FileCopy($current & "\" & $file, $destination & StringTrimLeft($current, StringLen($source)) & "\" & $file,$overwrite)
FileSetAttrib($destination & StringTrimLeft($current, StringLen($source)) & "\" & $file, $attrib)
EndIf
If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then
DirCreate($destination & StringTrimLeft($current, StringLen($source)) & "\" & $file)
FileSetAttrib($destination & StringTrimLeft($current, StringLen($source)) & "\" & $file, $attrib)
GUICtrlSetData($ProText, "拷贝路径:" & $current & "\" & $file)
ProgressCopy($current & "\" & $file, $destination, $UseMultiColour, $attrib, $overwrite,1)
EndIf
WEnd
FileClose($search)
If $overallpercent = 100 Then
GUICtrlSetData($Pro1Text, "已完成: 100% ")
GUICtrlSetData($Pro , 100)
GUICtrlSetData($Pro2, 100)
Sleep(100)
GUICtrlSetData($Pro1Text, 32)
GUICtrlSetState ( $Pro, 32)
GUICtrlSetState ( $Pro2, 32)
;~ GUICtrlSetState ( $kb, 16)
$Run1 = 0
EndIf
EndFunc ;==>ProgressCopy
Func _ChangeColour($start)
$Redness = Int(255 - ($start / 100 * 512))
If $Redness < 0 Then $Redness = 0
$Greeness = Int(($start / 100 * 512) - 257)
If $Greeness < 0 Then $Greeness = 0
$Blueness = Int(255 - ($Redness + $Greeness))
Return ($Redness * 256 * 256) + ($Greeness * 256) + $Blueness
EndFunc |