Jump to content
Sign in to follow this  
sensalim

_FileListToArray question

Recommended Posts

sensalim

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?

Share this post


Link to post
Share on other sites
monoceres

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!

Share this post


Link to post
Share on other sites
Zedna

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

Share this post


Link to post
Share on other sites
monoceres

So your Path musn't end with "\"

It works for me with a trailing '\' :) Edited by monoceres

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

Share this post


Link to post
Share on other sites
weaponx

It works for me with a trailing '\' :)

Was this using a root path or an actual folder?

Share this post


Link to post
Share on other sites
monoceres

Was this using a root path or an actual folder?

Tested with both :)

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

Share this post


Link to post
Share on other sites
Zedna

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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.