函数参考


_FileListToArray

列出指定路径下的文件和/或文件夹 (类似使用 Dir /B命令)

#Include <File.au3>
_FileListToArray($sPath [, $sFilter = "*" [, $iFlag = 0]])

参数

$sPath 要生成文件列表的路径.
$sFilter [可选参数] 要使用的可选过滤器, 默认是 *. 搜索 Autoit3 帮助文件中的 "WildCards" 关键字查看细节
$iFlag [可选参数] 指定是否返回文件的文件夹或者都要
$iFlag=0(默认) 文件和文件夹都返回
$iFlag=1 只返回文件
$iFlag=2 只返回文件夹

返回值

成功: 返回一个数组, 参考备注
失败: 0
@Error: 1 = 路径未找到或者无效
2 = 无效 $sFilter
3 = 无效 $iFlag
4 = 未找到任何文件

注意/说明

返回下方格式的一维数组:
$array[0] = 所有的文件\文件夹数量
$array[1] = 第一个文件\文件夹
$array[2] = 第二个文件\文件夹
$array[3] = 第三个文件\文件夹
$array[n] = 第 N个文件\文件夹

相关

示例/演示


#include <File.au3>
#include <Array.au3>

Local $FileList = _FileListToArray(@DesktopDir)
If @error = 1 Then
    MsgBox(4096, "", "No Folders Found.")
    Exit
EndIf
If @error = 4 Then
    MsgBox(4096, "", "No Files Found.")
    Exit
EndIf
_ArrayDisplay($FileList, "$FileList")