|
Dim $Files, $Size, $First = 0
_DirCopy("C:\Documents and Settings\Administrator", "d:\Drivers");要复制的文件夹
Func _DirCopy($Source, $Dest)
If Not FileExists($Dest) Then DirCreate($Dest)
If StringRight($Source, 1) = '\' Then $Source = StringTrimRight($Source, 1)
If StringRight($Dest, 1) <> '\' Then $Dest = $Dest & "\"
If $First = 0 Then
$Size = DirGetSize($Source, 1)
$Files = $Size[1]
ProgressOn("复制目录", "正在拷贝文件夹...") ;开启进度条,此处可以换成其他控件
$First = 1
EndIf
Dim $Search = FileFindFirstFile($Source & "\*.*")
While 1
Dim $File = FileFindNextFile($Search)
If @error Then ExitLoop
If FileGetAttrib($Source & "\" & $File) <> "D" Then
$Files -= 1
Dim $Percent = 100 - ($Files / $Size[1] * 100)
FileCopy($Source & "\" & $File, $Dest & $File, 1)
ProgressSet(Int($Percent), "进度: " & Int($Percent) & "%" & " 正在拷贝:" & $File)
Else
_DirCopy($Source & "\" & $File, $Dest & $File)
EndIf
WEnd
FileClose($Search)
Sleep(1000)
Exit
EndFunc ;==>_DirCopy |
|