home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 5010
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 7050
- LinkTopic = "Form1"
- ScaleHeight = 5010
- ScaleWidth = 7050
- StartUpPosition = 3 'Windows Default
- Begin MSComctlLib.TreeView tvwControl
- Height = 4335
- Left = 120
- TabIndex = 1
- Top = 480
- Width = 4815
- _ExtentX = 8493
- _ExtentY = 7646
- _Version = 393217
- Sorted = -1 'True
- Style = 7
- SingleSel = -1 'True
- Appearance = 1
- End
- Begin VB.CommandButton cmdEnd
- Caption = "End"
- Height = 375
- Left = 5760
- TabIndex = 0
- Top = 4560
- Width = 1215
- End
- Begin VB.Label lblMessage
- AutoSize = -1 'True
- Caption = "Label1"
- Height = 195
- Left = 120
- TabIndex = 2
- Top = 240
- Width = 480
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Dim FileSystem As Scripting.FileSystemObject ' FSO File system object
- Dim Drives As Scripting.Drives ' FSO Drives collection
- Private Sub Form_Load()
- Dim nodX As Node
- Dim Drive As Scripting.Drive
-
- ' Centre form on screen
- Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2
- ' Initialise the file system variables
- Set FileSystem = CreateObject("Scripting.FileSystemObject")
- Set Drives = FileSystem.Drives
-
- For Each Drive In Drives
- Set nodX = tvwControl.Nodes.Add(, tvwChild, Drive.DriveLetter & ":\", Drive.DriveLetter & ":")
- Next
- lblMessage = "Click on any drive letter to load its folders."
- End Sub
- Private Sub cmdEnd_Click()
- Unload Me
- Set Form1 = Nothing
- End
- End Sub
- Private Sub tvwControl_Click()
- Dim nodX As Node
- ' Show a wait message for long searches
- lblMessage = "Searching drive " & tvwControl.SelectedItem & " for folders ... please wait"
- ' Identify the selected node
- Set nodX = tvwControl.SelectedItem
- ' If it's a drive letter with no sub-tree, then scan it
- If (Right$(nodX.Text, 1) = ":") And (nodX.Children = 0) Then GetAllDrivesFolders nodX, nodX.Text & "\"
- nodX.Expanded = True
- lblMessage = "Total folders displayed : " & tvwControl.Nodes.Count - Drives.Count
- End Sub
- Public Sub GetAllDrivesFolders(ParentNode As Node, FileSpec As String)
- Dim nodX As Node
- Dim Folder As Scripting.Folder
- Dim SubFolders As Scripting.Folders
- Set SubFolders = FileSystem.GetFolder(FileSpec).SubFolders
- For Each Folder In SubFolders
- Set nodX = tvwControl.Nodes.Add(ParentNode.Key, tvwChild, FileSpec & Folder.Name, Folder.Name)
- GetAllDrivesFolders nodX, FileSpec & Folder.Name & "\"
- Next
- ParentNode.Sorted = True
- End Sub
-