本帖最后由 palkiller 于 2012-8-6 11:50 编辑 #include <Array.au3>
#Include <File.au3>
#NoTrayIcon
$begin=TimerInit()
$local_files=_FileListToArray(@WindowsDir&"\system32","*",1)
Dim $f[1][2]
For $i=1 To $local_files[0]
$lfile_size=size(FileGetSize(@WindowsDir&"\system32"&$local_files[$i]))
__ArrayAdd($f,$local_files[$i],$lfile_size)
Next
$time=TimerDiff($begin)
_ArrayDisplay($f,"用时"&Round($time/1000,2)&"秒")
Func __ArrayAdd(ByRef $avArray, $vValue0, $vValue1 = '', $0_auto = 1)
If Not IsArray($avArray) Then Return SetError(1, 0, -1)
Local $iUBound = UBound($avArray)
If UBound($avArray, 0) = 1 Then
If $0_auto And $avArray[0] = $iUBound-1 Then $avArray[0] += 1
ReDim $avArray[$iUBound + 1]
$avArray[$iUBound] = $vValue0
ElseIf UBound($avArray, 0) = 2 Then
If $0_auto And $avArray[0][0] = $iUBound-1 Then $avArray[0][0] += 1
ReDim $avArray[$iUBound + 1][2]
$avArray[$iUBound][0] = $vValue0
$avArray[$iUBound][1] = $vValue1
ElseIf UBound($avArray, 0) > 2 Then
Return SetError(2, 0, -1)
EndIf
Return $iUBound
EndFunc
Func size($size)
If $size<1024 Then
$size=$size&"B"
ElseIf $size>=1024 And $size<1048576 Then
$size=Round($size/1024,2)&"KB"
ElseIf $size>=1048576 And $size<1073741824 Then
$size=Round($size/1048576,2)&"MB"
ElseIf $size>=1073741824 And $size<1099511627776 Then
$size=Round($size/1073741824,2)&"GB"
Else
$size=Round($size/1099511627776,2)&"TB"
EndIf
Return $size
EndFunc
上面的代码遍历一个3000多文件的文件夹,耗时10秒多,太悲催了...不知道各位达人有没有更快捷的方法,求指点... |