Jump to content

Error with trying to list all files.


MasterX
 Share

Recommended Posts

I want to list all files on the pc with a treeview.

First it worked properly but then everytime i started it i got an error.

The adress blub points to blub the command read could not be executed.

Sorry if the error message is wrong mine is german :mellow:

here is the script.

#include<file.au3>
GUICreate("",300,300)
$a=GUICtrlCreateTreeView(5,5,200,200)
$b=_FileListToArray(@HomeDrive)
GUISetState()
func sarch()
    If StringInStr($search,".",1) then 
    
Else    
    $ne=FileGetLongName($search)
    $z=_FileListToArray($ne)
    If IsArray($z) Then
    for $m=1 to $z[0]
        GUICtrlCreateTreeViewItem($search&"\"&$z[$m],$y)
        $search=$ne&"\"&$z[$m]
        sarch()
    Next
    EndIf
EndIf
EndFunc
for $i=1 to $b[0]
$k=GUICtrlCreateTreeViewItem($b[$i],$a)
$search=$b[$i]
If StringInStr($search,".",1) then 
    
Else    
    $ne=FileGetLongName($b[$i])
    $ne=@HomeDrive&"\"&$ne
    $c=_FileListToArray($ne)
    If IsArray($c)=1 Then
    for $n=1 to $c[0]
        $y=GUICtrlCreateTreeViewItem($search&"\"&$c[$n],$k)
        $search=$ne&"\"&$c[$n]
        sarch()
    Next
    EndIf
EndIf   
Next
while 1
    Sleep(100)
WEnd
Link to comment
Share on other sites

I want to list all files on the pc with a treeview.

First it worked properly but then everytime i started it i got an error.

The adress blub points to blub the command read could not be executed.

Sorry if the error message is wrong mine is german :mellow:

here is the script.

#include<file.au3>
GUICreate("",300,300)
$a=GUICtrlCreateTreeView(5,5,200,200)
$b=_FileListToArray(@HomeDrive)
GUISetState()
func sarch()
    If StringInStr($search,".",1) then 
    
Else    
    $ne=FileGetLongName($search)
    $z=_FileListToArray($ne)
    If IsArray($z) Then
    for $m=1 to $z[0]
        GUICtrlCreateTreeViewItem($search&"\"&$z[$m],$y)
        $search=$ne&"\"&$z[$m]
        sarch()
    Next
    EndIf
EndIf
EndFunc
for $i=1 to $b[0]
$k=GUICtrlCreateTreeViewItem($b[$i],$a)
$search=$b[$i]
If StringInStr($search,".",1) then 
    
Else    
    $ne=FileGetLongName($b[$i])
    $ne=@HomeDrive&"\"&$ne
    $c=_FileListToArray($ne)
    If IsArray($c)=1 Then
    for $n=1 to $c[0]
        $y=GUICtrlCreateTreeViewItem($search&"\"&$c[$n],$k)
        $search=$ne&"\"&$c[$n]
        sarch()
    Next
    EndIf
EndIf   
Next
while 1
    Sleep(100)
WEnd
If you add this line to the start of your Sart function you will see that you are messing up the $search path.

ConsoleWrite($search & @CRLF)

I think something like thjis might fix it but not really tested.

#include<file.au3>
GUICreate("", 300, 300)
$a = GUICtrlCreateTreeView(5, 5, 200, 200)
$b = _FileListToArray(@HomeDrive)
GUISetState()
Global $deep, $its
For $i = 1 To $b[0]
    $k = GUICtrlCreateTreeViewItem($b[$i], $a)
    $search = $b[$i]
    ConsoleWrite($search & @CRLF)
    If StringInStr($search, ".", 1) Then

    Else
        $ne = FileGetLongName($b[$i])
        $ne = @HomeDrive & "\" & $ne
        $c = _FileListToArray($ne)
        If IsArray($c) = 1 Then
            For $n = 1 To $c[0]
                $y = GUICtrlCreateTreeViewItem($search & "\" & $c[$n], $k)
                $search = $ne & "\" & $c[$n]
                sarch($search)
            Next
        EndIf
    EndIf
Next
While 1
    Sleep(100)
WEnd

Func sarch($spath)
    Local $ne
    
    If StringInStr(FileGetAttrib($spath),"D") then
        $ne = FileGetLongName($spath)
        $z = _FileListToArray($ne)
        If IsArray($z) Then
            For $m = 1 To $z[0]
                $its += 1
                GUICtrlCreateTreeViewItem($search & "\" & $z[$m], $y)
        ; $search=$ne&"\"&$z[$m]
                sarch($ne & "\" & $z[$m])
            Next
        EndIf
    EndIf
EndFunc

Edit: changed if condition in sart function

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...