可以这样
但有限制,数组最多1600万个元素,递归最多384层
#include <array.au3>
Global $tmp[1]
dim $i = 0
$x = _filelist("d:\aaa",$tmp)
_ArrayDisplay($tmp)
Func _filelist($searchdir,ByRef $tmp)
$search = FileFindFirstFile($searchdir & "\*.*")
If $search = -1 Then Return -1
While 1
$file = FileFindNextFile($search)
If @error Then
FileClose($search)
Return -1
ElseIf $file = "." Or $file = ".." Then
ContinueLoop
ElseIf StringInStr(FileGetAttrib($searchdir & "\" & $file), "D") Then
_filelist($searchdir & "\" & $file,$tmp)
EndIf
If StringRight($file, 4) = ".exe" Then
$i += 1
;FileWriteLine(@ScriptDir&"\file.txt", $searchdir & "\" & $file & @CRLF)
_ArrayAdd($tmp,$searchdir & "\" & $file)
$tmp[0]+=1
EndIf
WEnd
EndFunc ;==>_filelist |