|
|
Title | Use FSO to create a FileInspector application that displays information about files |
Description | This example shows how to use FSO to create a FileInspector application that displays information about files in Visual Basic 6. |
Keywords | FSO, File System Object, file inspector, file, file attributes, file times, modification time, access time, creation time |
Categories | Files and Directories, Windows |
|
|
Thanks to Dipak Auddy.
The program uses a DriveListBox and DirListBox to let you select a directory. When you pick a directory, the listFiles subroutine displays information about the files in the directory in a ListView control.
|
|
Private Sub listFiles(ByVal Folder_Path As String)
Dim fL As Scripting.File
Dim LI As ListItem
Dim I As Integer
I = 0
'Clear the list...
ListView1.ListItems.Clear
'Unbound ImageList so we can clear images...
ListView1.SmallIcons = Nothing
ListView1.Icons = Nothing
ImageList1.ListImages.Clear
ImageList2.ListImages.Clear
'VB will not allow to bound uninit. imagelist
'so we add a dummy icon here and bound it
ImageList1.ListImages.Add 1, , appIcon
ImageList2.ListImages.Add 1, , Me.Icon
ListView1.SmallIcons = ImageList1
ListView1.Icons = ImageList2
On Error Resume Next
For Each fL In FSO.GetFolder(Folder_Path).Files
Set LI = ListView1.ListItems.Add()
I = I + 1
GetSmallShellIcon fL.Path, Picture1
GetBigShellIcon fL.Path, Picture2
ImageList1.ListImages.Add I + 1, , Picture1.Image
ImageList2.ListImages.Add I + 1, , Picture2.Image
With LI
.Icon = I + 1
.SmallIcon = I + 1
.Text = fL.Name
.SubItems(1) = fL.Type
.SubItems(2) = fL.Size
.SubItems(3) = parseAttrb(fL.Attributes)
.SubItems(4) = fL.DateCreated
.SubItems(5) = fL.DateLastModified
End With 'LI
Next fL
ListView1.Refresh
ArrangeLV ListView1
StatusBar1.Panels(1).Text = "Files Found : " & I
Screen.MousePointer = vbNormal
On Error GoTo 0
End Sub
|
|
|
|
|
|