Private Sub ScanFolder(FolderSpec)
Dim ThisFolder As Folder
Dim AllFolders As Folders
Dim ThisFile As File
Dim AllFiles As Files
Dim i As Integer
Set fso = New FileSystemObject
If Not Len(FolderSpec) = 1 Then
Set ThisFolder = fso.GetFolder(FolderSpec & "\")
Else
Set ThisFolder = fso.GetFolder(FolderSpec & ":")
End If
Set AllFolders = ThisFolder.SubFolders
For Each ThisFolder In AllFolders
Set AllFiles = ThisFolder.Files
If AllFiles.Count > 0 Then
For Each ThisFile In AllFiles
Set lstItem = frmMain.lvwFileList.ListItems.Add(, , ThisFile.Path)
lstItem.SubItems(1) = ThisFile.Size
Next
End If
Set AllFiles = Nothing
ScanFolder ThisFolder.Path
DoEvents
Next
Set ThisFolder = Nothing
Set AllFolders = Nothing
Set fso = Nothing
Set lstItem = Nothing
Unload Me
End Sub
Private Sub Form_Activate()
Dim drv As Drive
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
KeepOnTop Me
CenterForm Me
Response = InputBox("Enter a label for this volume.", "Enter volume label")
rs.Open dtaVolumes.RecordSource, dtaVolumes.ConnectionString, adOpenKeyset, adLockOptimistic
Set fso = New FileSystemObject
For Each drv In fso.Drives
If drv.DriveType = CDRom Then
If drv.IsReady = True Then
ScanFolder drv.DriveLetter
Else
Exit Sub
End If
End If
Next
For i = 1 To frmMain.lvwFileList.ListItems.Count
TotalCDSize = TotalCDSize + frmMain.lvwFileList.ListItems(i).SubItems(1)
rs.AddNew
rs!Name = Response
rs!Date_Created = Date
rs!Files = frmMain.lvwFileList.ListItems(i)
Next i
For i = 1 To frmMain.lvwFileList.ListItems.Count
BytesProcessed = BytesProcessed + frmMain.lvwFileList.ListItems(i).SubItems(1)
pbrProgress.Value = BytesProcessed / TotalCDSize
Next i
Set lstItem = frmMain.lvwVolumes.ListItems.Add(, , Response)
lstItem.SubItems(1) = Date
lstItem.SubItems(2) = frmMain.lvwFileList.ListItems.Count
frmMain.lvwFileList.ListItems.Clear
Set fso = Nothing
Set rs = Nothing
Set lstItem = Nothing
End Sub