Jump to content
Sign in to follow this  
0x90h

_FileListToArray issue

Recommended Posts

Valuater

This should do the trick

$Files_List = _MultiFileListToArray(@ScriptDir, "*.txt|*.ini")

; for display only
$GUI = GUICreate(' _MultiFileListToArray - DEMO')
$Edit1 = GUICtrlCreateEdit("", 50, 50, 300, 300)
For $x = 1 To UBound($Files_List) - 1
    GUICtrlSetData(-1, $Files_List[$x] & @CRLF, 1)
Next
GUISetState()

While GUIGetMsg() <> -3
WEnd
; end display only

Func _MultiFileListToArray($sPath, $sFilter = "*", $iFlag = 0)
    Local $hSearch, $sFile, $asFileList[1], $sCount
    If Not FileExists($sPath) Then Return SetError(1, 1, "")
    If (StringInStr($sFilter, "\")) Or (StringInStr($sFilter, "/")) Or (StringInStr($sFilter, ":")) Or (StringInStr($sFilter, ">")) Or (StringInStr($sFilter, "<")) Or (StringStripWS($sFilter, 8) = "") Then Return SetError(2, 2, "")
    $sFilter = (StringSplit($sFilter, "|"))
    If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "")
    For $sCount = 1 To $sFilter[0]
        $hSearch = FileFindFirstFile($sPath & "\" & $sFilter[$sCount])
        If $hSearch = -1 Then
            If $sCount = $sFilter[0] Then Return SetError(4, 4, $asFileList)
            ContinueLoop
        EndIf
        While 1
            $sFile = FileFindNextFile($hSearch)
            If @error Then
                SetError(0)
                ExitLoop
            EndIf
            If $iFlag = 1 And StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") <> 0 Then ContinueLoop
            If $iFlag = 2 And StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") = 0 Then ContinueLoop
            ReDim $asFileList[UBound($asFileList) + 1]
            $asFileList[0] = $asFileList[0] + 1
            $asFileList[UBound($asFileList) - 1] = $sFile
        WEnd
        FileClose($hSearch)
    Next
    Return $asFileList
EndFunc   ;==>_MultiFileListToArray

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
0x90h

this is just what i was lookin for :D

realy nice, thanks for your help.

regards

0x90h

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×