Jump to content

_FileListToArray question


Recommended Posts

my folder, let's say c:\ has 3 jpg files. I want to use this function to make an array.

so I use

$filelist = _FileListToArray("C:\", "*.jpg", 1)

but it spits out @error (4) - No File(s) Found.

How come?

Maybe the files are named ~something.jpeg?

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Here is reason:

Func _FileListToArray($sPath, $sFilter = "*", $iFlag = 0)

Local $hSearch, $sFile, $asFileList[1]

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 (StringInStr($sFilter, "|")) Or (StringStripWS($sFilter, 8) = "") Then Return SetError(2, 2, "")

If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "")

$hSearch = FileFindFirstFile($sPath & "\" & $sFilter)

If $hSearch = -1 Then Return SetError(4, 4, "")

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)

Return $asFileList

EndFunc ;==>_FileListToArray

So your Path musn't end with "\"

EDIT:

Unfortunatelly this is not described in HelpFile

But it can be easily handled inside this UDF.

I will create BUG ticket on BugTrack about that

Edited by Zedna
Link to comment
Share on other sites

Was this using a root path or an actual folder?

Yes I can confirm trailing backslash makes problems only on ROOT dir.

I think it's the same as my previously reported bug

http://www.autoitscript.com/forum/index.ph...st&p=443203

It's fixed in 3.2.11 beta 

EDIT: it was only on WIN9x

Edited by Zedna
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...