#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=i.ico
#AutoIt3Wrapper_outfile=ListAllDir.exe
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#Include <Array.au3>
$path = @ScriptDir
$DirList = myFileListToArray($path,0,2)
_ArrayDisplay($DirList)
Func myFileListToArray($sPath, $rPath = 0, $iFlag = 0, $sPathExclude = 0)
Local $asFileList[1]
$asFileList = myFileListToArrayTemp($asFileList, $sPath, $rPath, $iFlag, $sPathExclude)
Return $asFileList
EndFunc
Func myFileListToArrayTemp(ByRef $asFileList, $sPath, $rPath = 0, $iFlag = 0, $sPathExclude = 0)
Local $hSearch, $sFile
If Not FileExists($sPath) Then Return SetError(1, 1, "")
If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "")
$hSearch = FileFindFirstFile($sPath & "\*")
If $hSearch = -1 Then Return SetError(4, 4, "")
While 1
$sFile = FileFindNextFile($hSearch)
If @error Then
SetError(0)
ExitLoop
EndIf
If $sPathExclude And StringLen($sPathExclude) > 0 Then $sPathExclude = StringSplit($sPathExclude, ",")
$bExclude = False
If IsArray($sPathExclude) Then
For $ii = 1 To $sPathExclude[0] Step 1
If StringInStr($sPath & "" & $sFile, $sPathExclude[$ii]) Then
$bExclude = True
ExitLoop
EndIf
Next
EndIf
If $bExclude Then ContinueLoop
Select
Case StringInStr(FileGetAttrib($sPath & "" & $sFile), "D")
Select
Case $iFlag = 1
myFileListToArrayTemp($asFileList, $sPath & "" & $sFile, $rPath, $iFlag, $sPathExclude)
ContinueLoop
Case $iFlag = 2 Or $iFlag = 0
If $rPath Then
If Not StringRegExp($sPath & "" & $sFile, $rPath, 0) Then
myFileListToArrayTemp($asFileList, $sPath & "" & $sFile, $rPath, $iFlag, $sPathExclude)
ContinueLoop
Else
myFileListToArrayTemp($asFileList, $sPath & "" & $sFile, $rPath, $iFlag, $sPathExclude)
EndIf
Else
myFileListToArrayTemp($asFileList, $sPath & "" & $sFile, $rPath, $iFlag, $sPathExclude)
EndIf
EndSelect
Case Not StringInStr(FileGetAttrib($sPath & "" & $sFile), "D")
If $iFlag = 2 Then ContinueLoop
If $rPath And Not StringRegExp($sPath & "" & $sFile, $rPath, 0) Then ContinueLoop
EndSelect
ReDim $asFileList[UBound($asFileList) + 1]
$asFileList[0] = $asFileList[0] + 1
;为了方便查看所有多加了/\
$asFileList[UBound($asFileList) - 1] = $sPath & "\//////" & $sFile
WEnd
FileClose($hSearch)
Return $asFileList
EndFunc
目前此代码直接列出来当前所有目录路径