moonboor 发表于 2009-9-21 20:41:45

listview的问题

Func file()
        $seach = FileFindFirstFile("c:\windows\*.exe")
        If $seach = -1 Then
                MsgBox(1,"title","无法打开文件")
                Exit
        EndIf
        While 1
                $file = FileFindNextFile($seach)
                $filesize = FileGetSize($file)
                $list = $file & "|" & $filesize
                If @error = -1 Then ExitLoop
                $sr = GUICtrlCreateListViewItem($list,$listview)
        WEnd
EndFunc

这段程序写入listview以后。怎么还写入了很多空值。怎么解决呢。请大家跟我说一说。谢谢。

afan 发表于 2009-9-21 20:45:48

FileGetSize 里面的路径不是完整路径

afan 发表于 2009-9-21 20:53:08

本帖最后由 afan 于 2009-9-21 23:05 编辑

这样改下吧~
$filesize = FileGetSize(@WindowsDir & '\' & $file)

moonboor 发表于 2009-9-21 21:01:35

不可否认,这样确实可以把.exe的文件大小都显示出来。但是还是有空值的出现。

afan 发表于 2009-9-21 21:03:01

那你就自己弄吧

顽固不化 发表于 2009-9-21 22:27:48

唉,人家给的思路都这样了还不能引玉?#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 620, 447, 192, 124)
$listview=GUICtrlCreateListView("文件名|大小(Kbyte)",10,10,600,400)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
file()
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
Func file()
      $seach = FileFindFirstFile(@WindowsDir&'\*.exe')
      If $seach = -1 Then
                MsgBox(1, "title", "无法打开文件")
                Exit
      EndIf
      While 1
                $file = FileFindNextFile($seach)
                                If @errorThen ExitLoop
                $filesize = int(FileGetSize(@WindowsDir&'\' & $file)/1024*1000)/1000
                $list = $file & "|" & $filesize
                $sr = GUICtrlCreateListViewItem($list, $listview)
      WEnd
EndFunc   ;==>file

auhj887 发表于 2010-4-11 21:49:35

好好。。。。。。。学习。。。。。。。。。
页: [1]
查看完整版本: listview的问题