本帖最后由 lixiaolong 于 2012-3-22 16:47 编辑
随便改了一点,可以搜索多个格式,只检查文件的.
要搜索所有格式直接用_FileListToArray()吧.
#include <Array.au3>
; 只检查文件
$a = __FileListToArray('C:\Windows', "*.exe|*.dll|*.txt")
_ArrayDisplay($a)
Func __FileListToArray($sPath, $sFilter)
Local $Count = 1, $sFileList, $sDelim = "|"
$sFilter = StringReplace($sFilter, '*', '')
$search = FileFindFirstFile($sPath & "\*.*")
If $search = -1 Then
MsgBox(0, "错误", "没有匹配搜索的文件/目录")
Return SetError(1)
EndIf
$Split = StringSplit($sFilter, '|', 1)
If Not @error Then $Count = $Split[0]
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
If Not @extended Then
For $i = 1 To $Count
If StringRight($file, 4) = $Split[$i] Then
$sFileList &= $sDelim & $sPath & '\' & $file
EndIf
Next
EndIf
WEnd
FileClose($search)
If Not $sFileList Then Return SetError(1)
Return StringSplit(StringTrimLeft($sFileList, 1), "|")
EndFunc ;==>__FileListToArray
|