Dim X As Integer, Img As Integer Dim Y As Long Drive1.Refresh Dir1.Refresh File1.Refresh ListView1.ListItems.Clear If Mid(Dir1.Path, Len(Dir1.Path), 1) = "\" Then strPath = Dir1.Path Else: strPath = Dir1.Path & "\" End If Label1.Caption = strPath If Len(Label1.Caption) > 30 Then Label1.Caption = "..." & Trim(Right(Label1.Caption, 30)) End If For X = 0 To File1.ListCount - 1 Img = ImgNumber(File1.List(X)) With ListView1.ListItems.Add(, , File1.List(X), Img, Img) Y = Str(FileLen(strPath & File1.List(X))) Dim a As String a = Format((FileLen(strPath & File1.List(X)) / 1000), "### ### ###.##") .SubItems(1) = IIf(Y = 0, 0 & "字节", a & "字节") ' .SubItems(1) = Format((FileLen(strPath & File1.List(X)) / 1000), "### ### ###.##") & "字节" .SubItems(2) = FileDateTime(strPath & File1.List(X)) .SubItems(3) = Str(FileLen(strPath & File1.List(X))) End With NextPrivate Function ImgNumber(strFileName As String) As Integer Dim strExt As String strExt = Mid$(strFileName, InStrRev(strFileName, ".") + 1) On Error Resume Next Select Case LCase(strExt) Case "avi", "mpg", "mpeg", "mov" ImgNumber = 8 Case "gif" ImgNumber = 4 Case "jpg", "jpeg", "jpe", "bmp" ImgNumber = 1 Case "htm", "html", "xml", "asp" ImgNumber = 2 Case "js", "css", "cgi" ImgNumber = 5 Case "mp3", "ram", "au", "vaw" ImgNumber = 6 Case "zip", "arj" ImgNumber = 7 Case "exe", "com", "bat" ImgNumber = 9 Case "txt", "log", "doc", "rtf", "ftp", "ini", "dat" ImgNumber = 3 Case Else ImgNumber = 10 End Select End Function
listview1.SelectedItem.Icon =loadpicture()
EMAIL:[email protected]
Dim Y As Long
Drive1.Refresh
Dir1.Refresh
File1.Refresh
ListView1.ListItems.Clear
If Mid(Dir1.Path, Len(Dir1.Path), 1) = "\" Then
strPath = Dir1.Path
Else: strPath = Dir1.Path & "\"
End If
Label1.Caption = strPath
If Len(Label1.Caption) > 30 Then
Label1.Caption = "..." & Trim(Right(Label1.Caption, 30))
End If
For X = 0 To File1.ListCount - 1
Img = ImgNumber(File1.List(X))
With ListView1.ListItems.Add(, , File1.List(X), Img, Img)
Y = Str(FileLen(strPath & File1.List(X)))
Dim a As String
a = Format((FileLen(strPath & File1.List(X)) / 1000), "### ### ###.##")
.SubItems(1) = IIf(Y = 0, 0 & "字节", a & "字节")
' .SubItems(1) = Format((FileLen(strPath & File1.List(X)) / 1000), "### ### ###.##") & "字节"
.SubItems(2) = FileDateTime(strPath & File1.List(X))
.SubItems(3) = Str(FileLen(strPath & File1.List(X)))
End With
NextPrivate Function ImgNumber(strFileName As String) As Integer
Dim strExt As String
strExt = Mid$(strFileName, InStrRev(strFileName, ".") + 1)
On Error Resume Next
Select Case LCase(strExt)
Case "avi", "mpg", "mpeg", "mov"
ImgNumber = 8
Case "gif"
ImgNumber = 4
Case "jpg", "jpeg", "jpe", "bmp"
ImgNumber = 1
Case "htm", "html", "xml", "asp"
ImgNumber = 2
Case "js", "css", "cgi"
ImgNumber = 5
Case "mp3", "ram", "au", "vaw"
ImgNumber = 6
Case "zip", "arj"
ImgNumber = 7
Case "exe", "com", "bat"
ImgNumber = 9
Case "txt", "log", "doc", "rtf", "ftp", "ini", "dat"
ImgNumber = 3
Case Else
ImgNumber = 10
End Select
End Function