Description: 列出目录下所有文件或文件夹,包括子文件夹.(autoit官方版本_FileListToArray不包括搜索子文件夹,也不支持正则表达式)
Syntax: myFileListToArray($sPath,$rPath=0, $iFlag = 0,$sPathExclude=0)
Parameter(s): $sPath = Path to generate filelist for 要搜索的路径
$iFlag = determines weather to return file or folders or both
$rPath = The regular expression to compare. StringRegExp Function Reference For details
用于搜索的正则表达式,用法同StringRegExp函数
$iFlag=0(Default) Return both files and folders 返回所有文件和文件夹
$iFlag=1 Return files Only 仅返回文件
$iFlag=2 Return Folders Only 仅返回文件夹
$sPathExclude = when word in path, the file/folder
will exclude,mulite words separate by comma(,)
在路径中要要排除的词语,多个有,分隔
Requirement(s): autoit v3.2.2.0
Return Value(s): On Success - Returns an array containing the list of files and folders in the specified path
On Failure - Returns the an empty string "" if no files are found and sets @Error on errors
@Error=1 Path not found or invalid
@Error=3 Invalid $iFlag
@Error=4 No File(s) Found
Note(s): The array returned is one-dimensional and is made up as follows:
&nbs
p; $array[0] = Number of Files\Folders returned 返回文件/文件夹的数量
$array[1] = 1st File\Folder (not include $sPath) 第一个文件/文件夹
$array[2] = 2nd File\Folder (not include $sPath)
$array[3] = 3rd File\Folder (not include $sPath)
$array[n] = nth File\Folder (not include $sPath)
Special Thanks to SolidSnake <MetalGX91@GMail.com> (his _FileListToArray)
例子:
; *******************************************************
; 例子 - 搜索D盘目录下的QQ文件
; *******************************************************
#include "_FileListToArray.au3"
$sPath = "D:\"
$aFile = myFileListToArray($sPath, "QQ.exe", 1, "manifest,images")
If IsArray($aFile) Then
For $i = 1 To $aFile[0] Step 1
ConsoleWrite($i & "=" & $aFile[$i] & @CRLF)
MsgBox(0, "找到"&$i&"个QQ文件", $aFile[$i])
Next
EndIf
|