Jump to content

_FileListToArray problem


LongBowNZ
 Share

Recommended Posts

$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
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
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...