本帖最后由 水木子 于 2010-11-8 17:43 编辑
2楼正解!
#include <File.au3>
#include <GuiListBox.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
GUICreate("文件搜索", 380, 350)
$ListView1 = GUICtrlCreateListView("路径|占用空间", 5, 5, 370, 300)
_GUICtrlListView_SetColumnWidth($ListView1, 0, 280)
$Input1 = GUICtrlCreateInput("", 5, 310, 300, 21)
$But1 = GUICtrlCreateButton("浏览", 305, 308, 70, 25, $WS_GROUP)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case - 3
Exit
Case $But1
$var = FileSelectFolder("选择一个文件夹.", "")
If @error <> 1 Then
GUICtrlSetData($Input1, $var)
If StringRight($var, 1) = '\' Then $var = StringLeft($var, StringLen($var) - 1)
_GUICtrlListBox_ResetContent($ListView1)
Findfile($var)
EndIf
EndSwitch
WEnd
Func Findfile($Path)
$aFileList = _FileListToArray($Path, '*', 2)
If Not @error Then
For $i = 1 To $aFileList[0]
$sFolder = DirGetSize($Path & '\' & $aFileList[$i])
GUICtrlCreateListViewItem($Path & $aFileList[$i] & '|' & Round($sFolder / 1048576) & '(MB)', $ListView1)
;Findfile($Path & '\' & $aFileList[$i]) ;递归子文件或文件夹
Next
EndIf
EndFunc ;==>Findfile
|