Jump to content
Sign in to follow this  
LongBowNZ

_FileListToArray problem

Recommended Posts

maqleod

$ModList=_FileListToArray($BF_ModDir, Default, 2)
For $i = 1 To $ModList[0] Step 1
    GUICtrlCreateListViewItem($ModList[$i], $ModListView)
Next

Gives me the error

:)

You should test for these as it appears your array is not being created:

@Error:

1 = Path not found or invalid

2 = Invalid $sFilter

3 = Invalid $iFlag

4 = No File(s) Found


[u]You can download my projects at:[/u] Pulsar Software

Share this post


Link to post
Share on other sites
LongBowNZ

You should test for these as it appears your array is not being created:

@Error:

1 = Path not found or invalid

2 = Invalid $sFilter

3 = Invalid $iFlag

4 = No File(s) Found

$ModList=_FileListToArray($BF_ModDir, Default, 2)
If @Error=1 Then
    MsgBox(0, "", "Path not found or invalid.")
    Exit
EndIf
If @Error=2 Then
    MsgBox(0, "", "Invalid $sFilter.")
    Exit
EndIf
If @Error=3 Then
    MsgBox(0, "", "Invalid $iFlag.")
    Exit
EndIf
If @Error=4 Then
    MsgBox(0, "", "No File(s) Found.")
    Exit
EndIf
For $i = 1 To $ModList[0] Step 1
    GUICtrlCreateListViewItem($ModList[$i], $ModListView)
Next

"No File(s) Found" is what it comes up with even though in the folder "$BF_ModDir" there is 13 Folders and I thought setting the last param in _FileListToArray to 2 makes it return folders?

Share this post


Link to post
Share on other sites
Nahuel

This should work:

$ModList=_FileListToArray($BF_ModDir, "*.", 2)
If @Error=1 Then
    MsgBox(0, "", "Path not found or invalid.")
    Exit
EndIf
If @Error=2 Then
    MsgBox(0, "", "Invalid $sFilter.")
    Exit
EndIf
If @Error=3 Then
    MsgBox(0, "", "Invalid $iFlag.")
    Exit
EndIf
If @Error=4 Then
    MsgBox(0, "", "No File(s) Found.")
    Exit
EndIf
For $i = 1 To $ModList[0] Step 1
    GUICtrlCreateListViewItem($ModList[$i], $ModListView)
Next

I don't know if it'll be of any help, but you could check out 'Rename all files in a directory' in my signature. It uses that function.

Edited by Nahuel

Share this post


Link to post
Share on other sites
Nahuel

Here:

#include <file.au3>
#include <GUIConstants.au3>


GUICreate("Form1", 285, 308, 269, 113)
$ModListView=GUICtrlCreateListView("Test                ",15,15)
GUISetState(@SW_SHOW)


$BF_ModDir=@ProgramFilesDir
$ModList=_FileListToArray($BF_ModDir, "*.", 2)
If @Error=1 Then
    MsgBox(0, "", "Path not found or invalid.")
    Exit
EndIf
If @Error=2 Then
    MsgBox(0, "", "Invalid $sFilter.")
    Exit
EndIf
If @Error=3 Then
    MsgBox(0, "", "Invalid $iFlag.")
    Exit
EndIf
If @Error=4 Then
    MsgBox(0, "", "No File(s) Found.")
    Exit
EndIf
For $i = 1 To $ModList[0] Step 1
    GUICtrlCreateListViewItem($ModList[$i], $ModListView)
Next
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
Stalker0

The only thing I have to add is make sure you are including all of the files you need, most of my array errors come from that simple thing.

Share this post


Link to post
Share on other sites
LongBowNZ

This should work:

$ModList=_FileListToArray($BF_ModDir, "*.", 2)
Filter param was the problem. In the help file it says the Default is "*." but putting Default doesn't work, don't know if thats a bug or not?

Anyway thanks Nahuel :)

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  

×