[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tree directories and files


El 15/10/24 a las 9:59, Jorge Carrión escribió:
Here is a Control who do that. Hope it wors for you.

Perfect, it's just what I needed. I just changed the code a little bit to use it as a method.

/Perfecto, es justo lo que necesitaba. Solo cambie un poco el código para usarlo como método/

Public Sub FillTree(tv As TreeView, path As String, seeNext As Boolean)

  Dim aDir As String[]
  Dim s, c, clave As String
  Dim pic As Picture
  Dim n As Integer
  Dim ok As Boolean

  If Not IsDir(path) Then path = File.Dir(path)
  Inc Application.Busy
  If $showhidden Then c = "A"
  c = "ls --group-directories-first -1B" & c & " \"" & path & "\""
  Shell c To s
  adir = Split(s, gb.NewLine, "", True)
  Try tv.Add(path, File.Name(path), Picture["icon:/16/directory"]) 'try is faster than if not me.exist(path) then...
  If tv.Count = 1 Then tv[path].Expanded = True
  For Each s In adir
    Inc n
    If s = "." Or s = ".." Then Continue
    clave = path &/ s
    If IsDir(clave) Then
      pic = Picture["icon:/16/directory"]
      Try tv.Add(clave, File.Name(s), pic, path) 'try is faster than if not me.exist(path) then...       If seeNext And n < $max Then 'for speed reasons, only search in second level for firts 500 directories
        FillTree(tv, clave, False)
      Endif
    Else
      If Not $showfiles Then Continue
      If $Filtro Then
        ok = LCase(clave) Like LCase($Filtro)
        If $exclude Then
          If ok Then Continue
        Else
          If Not ok Then Continue
        Endif
      Endif
      pic = Desktop.GetFileIcon(clave, 16)
      If Not tv.Exist(clave) Then tv.Add(clave, File.Name(s), pic, path)
    Endif
  Next
  Dec Application.Busy

End

Thanks Shordi.

Martin.


References:
Tree directories and filesSystem64 Development <64xcode@xxxxxxxxx>
Re: Tree directories and filesJorge Carrión <shordi@xxxxxxxxx>