Private Sub Form_Load()
ListView1.ColumnHeaders.Add 1, , "名称", ListView1.Width / 4
ListView1.ColumnHeaders.Add 2, , "路径", ListView1.Width / 3, 0
ListView1.ColumnHeaders.Add 3, , "大小", ListView1.Width / 6, 1
ListView1.ColumnHeaders.Add 4, , "修改时间", ListView1.Width / 4, 0
End Sub
Private Sub Command1_Click()
If Text1.Text <> "" Then
If InStr(1, Text1.Text, "*") = 0 Then
Text1.Text = Text1.Text + "*.*"
End If
ListView1.ListItems.Clear
Form1.Height = 6810
ListView1.Visible = True
Form1.Refresh
strres = Dir(Drive1.Drive + "\" + Text1.Text)
Do While strres <> ""
Dim li As ListItem
Set li = ListView1.ListItems.Add(, , strres)
ListView1.ListItems(li.Index).ListSubItems.Add , , Drive1.Drive + "\"
Set ufile = fs1.GetFile(Drive1.Drive + "\" + strres)
dxstr = Format(Int(ufile.Size / 1024), "###,###") + "KB"
If dxstr = "KB" Then
dxstr = "1KB"
End If
ListView1.ListItems(li.Index).ListSubItems.Add , , dxstr
ListView1.ListItems(li.Index).ListSubItems.Add , , Str(ufile.DateLastModified)
strres = Dir
Loop
ListView1.Refresh
If Check1.Value = 1 Then
Findfolder Drive1.Drive + "\"
End If
Else
MsgBox "请输入搜索内容", vbOKOnly, "警告"
End If
End Sub
Private Function Findfolder() As String
Dim fld As Folder
Dim subfld As Folder
Dim strres As String
Set fld = fsl.GetFolder(pathstr)
Set fld = fld.SubFolders
If flds.Count > 0 Then
For Each subfld In flds
strres = Dir(subfld.Path + "\" + Text1.Text)
Do While strres <> ""
Dim li As ListItem
Set li = ListView1.ListItems.Add(, , strres)
ListView1.ListItems(li.Index).ListSubItems.Add , , subfld.Path
Set ufile = fsl.GetFile(subfld.Path + "\" + strres)
dxstr = Format(Int(ufile.Size / 1024), "###,###") + "KB"
If dxstr = "KB" Then
dxstr = "1KB"
End If
ListView1.ListItems(li.Index).ListSubItems.Add , , dxstr
ListView1.ListItems(li.Index).ListSubItems.Add , , Str(ufile.DateLastModified)
ListView1.Refresh
strres = Dir
Loop
Findfolder subfld.Path
Next
End If
End Function
请教高手,编辑时在红色代码那儿提示错误的参数号或无效的属性赋值,应该怎么改,望各位给予指点,不胜感激!