Jump to content

List all files in C onto a listbox or listview


Recommended Posts

I want to list all files in C onto a listbox or listview.

I tried this code:

#include<file.au3>
#include<array.au3>
#include<ListViewConstants.au3>
#include<GuiListView.au3>
...
Run("C:\WINDOWS\system32\cmd.exe" )
Run(@ComSpec & " /c dir " & "C:\*.* /s /b /a-d > Filec.log {ENTER}", "", @SW_HIDE)
Run(@ComSpec & " /c dir " & "D:\*.* /s /b /a-d > Filed.log {ENTER}", "", @SW_HIDE)
$ln=_FileCountLines("filec.log")
Dim $a [$ln] [1]
_FileReadToArray("Filec.log", $a)
$l2=GUICtrlCreateListView("", 5, 325, 500, 70)
_GUICtrlListView_BeginUpdate(-1)
_GUICtrlListView_Addarray(-1, $a)
_GUICtrlListView_EndUpdate(-1)

But it cannot work. There is an error in the file "GUIListView.au3"

Who can help me solve my task.

Edited by billgatetlhai
Link to comment
Share on other sites

  • Moderators

I want to list all files in C onto a listbox or listview.

I tried this code:

#include<file.au3>
#include<array.au3>
#include<ListViewConstants.au3>
#include<GuiListView.au3>
...
Run("C:\WINDOWS\system32\cmd.exe" )
Run(@ComSpec & " /c dir " & "C:\*.* /s /b /a-d > Filec.log {ENTER}", "", @SW_HIDE)
Run(@ComSpec & " /c dir " & "D:\*.* /s /b /a-d > Filed.log {ENTER}", "", @SW_HIDE)
$ln=_FileCountLines("filec.log")
Dim $a [$ln] [1]
_FileReadToArray("Filec.log", $a)
$l2=GUICtrlCreateListView("", 5, 325, 500, 70)
_GUICtrlListView_BeginUpdate(-1)
_GUICtrlListView_Addarray(-1, $a)
_GUICtrlListView_EndUpdate(-1)

But it cannot work. There is an error in the file "GUIListView.au3"

Who can help me solve my task.

The error is not in GUIListView.au3, it's in that code!! Read the help file on how to use the functions properly before posting in the forum for support with something that just won't work.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Look at the help file for _GUICtrlListBox_Dir() function. Below is the help file example modified a little bit.

#include <GUIListBox.au3>
#include <GuiConstantsEx.au3>
#include <Constants.au3>

Opt('MustDeclareVars', 1)

$Debug_LB = False ; Check ClassName being passed to ListBox functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
    Local $hListBox

    ; Create GUI
    GUICreate("List Box Dir", 400, 296)
    $hListBox = GUICtrlCreateList("", 2, 2, 396, 296)
    GUISetState()

    ; Add files
    _GUICtrlListBox_BeginUpdate($hListBox)
    _GUICtrlListBox_ResetContent($hListBox)
    _GUICtrlListBox_InitStorage($hListBox, 100, 4096)
    _GUICtrlListBox_Dir($hListBox, "C:\*.*", $DDL_HIDDEN + $DDL_SYSTEM)
    _GUICtrlListBox_EndUpdate($hListBox)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
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...