Jump to content

Search the Community

Showing results for tags 'filestructure'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. So I am trying to create a file tree structure Using _FileListToArrayRec with GuiCtrlCreateTreeView. But i have some problems with levels of directorys. In my mind there is nothing wrong with my logic, but obviously it is, since i dont get the output i want Here is a printscreen of the outcome, the array is sorted so it feels like it should be pretty easy, but its not Here is the working code #include <File.au3> #include <Array.au3> #include <GUITreeview.au3> #include <WINapiSHELLEX.au3> Local $hGI = GUICreate("test", 500,500) Local $hTreeView = GUICtrlCreateTreeView(0,0,500,500) GUISetState() Local $arr = _GuictrlTreeview__FileListToArrayRec($hTreeView,"C:\Autoit\REMOVE", "*.au3||BackUp;.git*;___TrashCan") _ArrayDisplay($arr) Func _GuictrlTreeview__FileListToArrayRec($hTreeView, $sPath, $sFilter) if StringRight($sPath,1) == "\" Then $sPath = StringLeft($sPath, StringLen($sPath) - 1) if not FileExists($sPath) Then Return SetError(1,0,0) Local $aFileList = _FileListToArrayRec($sPath, $sFilter, $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH) if @error Then Return SetError(1,0,0) Local $aParents[1] = [0] Local $sLastParentDirectory = False Local $hLastParentTreeItem = False Local $hLastParentChildItem = False ; Set default icons (late rreplaced with file associated icon $hImageList = _GUIImageList_Create(16, 16, 5, 1) _GUICtrlTreeView_SetNormalImageList($hTreeView, $hImageList) ; Begin tree update _GUICtrlTreeView_BeginUpdate($hTreeView) For $i = 1 To $aFileList[0] Local $sCurFullFilePath = $aFileList[$i] Local $sCurFileName = _Misc_GetFileName($aFileList[$i], False) ;Get da icon Local $hIcon = _WinAPI_ShellExtractAssociatedIcon($sCurFullFilePath, 1) Local $hIcon_Index = _GUIImageList_ReplaceIcon($hImageList, -1, $hIcon) ;If directory If FileGetAttrib($sCurFullFilePath) == "D" Then ; Check if sub has file to add If StringLeft($sCurFullFilePath, StringLen($sLastParentDirectory)) == $sLastParentDirectory Then $hLastParentChildItem = _GUICtrlTreeView_AddChild($hTreeView, $hLastParentTreeItem, $sCurFileName, $hIcon_Index, $hIcon_Index) ;Loop will end here ContinueLoop EndIf ;Create new parent folder & Update parents $sLastParentDirectory = $sCurFullFilePath $hLastParentTreeItem = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("%s", $sCurFileName), $hIcon_Index, $hIcon_Index) Else If Not $hLastParentChildItem Then ;ConsoleWrite($hLastParentTreeItem&" "&$sCurFileName&@CRLF) _GUICtrlTreeView_AddChild($hTreeView, $hLastParentTreeItem, $sCurFileName, $hIcon_Index, $hIcon_Index) Else _GUICtrlTreeView_AddChild($hTreeView, $hLastParentChildItem, $sCurFileName, $hIcon_Index, $hIcon_Index) EndIf EndIf Next ; End update _GUICtrlTreeView_EndUpdate($hTreeView) Return $aFileList EndFunc Func _Misc_GetFileName($sFilePath, $KeepExtension = True) ; Gets the filename Local $StringSPlit = StringSplit($sFilePath, "\") If Not $KeepExtension Then Return StringRegExpReplace($StringSPlit[$StringSPlit[0]], "\.(.*?)[a-zA-Z1234567890_-]{1,}+", "") Return $StringSPlit[$StringSPlit[0]] EndFunc ;==>_Misc_GetFileName Any tips ? Thanks in advance
×
×
  • Create New...