Wb-FreeKill Posted May 20, 2005 Share Posted May 20, 2005 (edited) Okay i want to create a listview like when you browse in regedit.. it have to show all files and foldes.. Like this: C:\ ---Programes ------Myprogram E:\ ---Movies ------MyMovie What is the best and fastets way of doing this.. maybe i could use this in some kind of way be splitting the resault and create listview items by that? expandcollapse popup#Include <GUIConstants.au3> GUICreate("BrowseDemo",400,400) $TreeView = GUICtrlCreateTreeView(20,20,200,300) $a = _FileSearch("C:\games\","*.*",1) Msgbox(0,"File:",$a[1]) GUISetState() While 1 $msg = GUIGetmsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd Func _FileSearch($szRoot,$szMask,$nOption) $hFile = 0 $szBuffer = "" $szReturn = "" $szPathList = "*" Dim $aNULL[1] If Not StringInStr($szMask,"\") Then $szRoot = $szRoot Else While StringInStr($szMask,"\") $szRoot = $szRoot & StringLeft($szMask,StringInStr($szMask,"\")) $szMask = StringTrimLeft($szMask,StringInStr($szMask,"\")) Wend EndIf If $nOption = 0 Then _FileSearchUtil($szRoot, $szMask, $szReturn) Else While 1 sleep(10) $hFile = FileFindFirstFile($szRoot & "*.*") If $hFile >= 0 Then $szBuffer = FileFindNextFile($hFile) While Not @ERROR If $szBuffer <> "." And $szBuffer <> ".." And _ StringInStr(FileGetAttrib($szRoot & $szBuffer),"D") Then _ $szPathList = $szPathList & $szRoot & $szBuffer & "*" $szBuffer = FileFindNextFile($hFile) Wend FileClose($hFile) EndIf _FileSearchUtil($szRoot, $szMask, $szReturn) If $szPathList == "*" Then ExitLoop $szPathList = StringTrimLeft($szPathList,1) $szRoot = StringLeft($szPathList,StringInStr($szPathList,"*")-1) & "\" $szPathList = StringTrimLeft($szPathList,StringInStr($szPathList,"*")-1) Wend EndIf If $szReturn = "" Then $aNULL[0] = 0 Return $aNULL Else Return StringSplit(StringTrimRight($szReturn,1),"*") EndIf EndFunc Func _FileSearchUtil(ByRef $ROOT, ByRef $MASK, ByRef $RETURN) $hFile = FileFindFirstFile($ROOT & $MASK) If $hFile >= 0 Then $szBuffer = FileFindNextFile($hFile) While Not @ERROR If $szBuffer <> "." And $szBuffer <> ".." Then _ $RETURN = $RETURN & $ROOT & $szBuffer & "*" $szBuffer = FileFindNextFile($hFile) Wend FileClose($hFile) EndIf EndFunc Edited May 20, 2005 by Wb-FreeKill Link to comment Share on other sites More sharing options...
Wb-FreeKill Posted May 20, 2005 Author Share Posted May 20, 2005 This is what ive made so far, i cant get it to add all subfolders.. Anyone brainie who know what to do? expandcollapse popup#Include <GUIConstants.au3> GUICreate("BrowseDemo",400,400) $TreeView = GUICtrlCreateTreeView(20,20,200,300) $HDDrives = DrivegetDrive("FIXED") For $i = 1 To $HDDrives[0] Search($HDDrives[$i] & "\","*.*") Next GUISetState() While 1 $msg = GUIGetmsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd Func Search($SearchPath,$FileType) $Item1 = GUICtrlCreateTreeViewItem(StringUpper($SearchPath),$TreeView) $Search = FileFindFirstFile($SearchPath & $FileType) If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf $Count = 1 DIM $SubTree[20] DIM $SubTree1[999] While 1 $File = FileFindNextFile($search) If @error Then ExitLoop $Attrib = FileGetAttrib($SearchPath & $File) If StringInStr($Attrib,"D") Then $SubTree[$Count] = GUICtrlCreateTreeViewItem($Count & $File,$Item1) $Count = $Count +1 EndIf WEnd FileClose($Search) EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now