Sign in to follow this  
Followers 0
billgatetlhai

List all files in C onto a listbox or listview

4 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
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

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  
Followers 0