News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

Use FSO to create a FileInspector application that displays information

Started by nandagopal, Nov 17, 2008, 07:36 PM

Previous topic - Next topic

nandagopal

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