VERSION 5.00
Begin VB.Form frmFileList
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "文件列表"
ClientHeight = 3810
ClientLeft = 165
ClientTop = 855
ClientWidth = 7845
LinkTopic = "Form1"
ScaleHeight = 3810
ScaleWidth = 7845
StartUpPosition = 3 '窗口缺省
Begin VB.ListBox lstSize
Height = 3120
Left = 6360
TabIndex = 7
Top = 360
Width = 975
End
Begin VB.ListBox lstDBM
Height = 3120
Left = 3840
TabIndex = 5
Top = 360
Width = 2415
End
Begin VB.DirListBox Dir1
Height = 3240
Left = 1440
TabIndex = 3
Top = 360
Width = 2295
End
Begin VB.DriveListBox Drive1
Height = 300
Left = 120
TabIndex = 2
Top = 360
Width = 1215
End
Begin VB.Label lblSize
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "数据库大小(字节)"
ForeColor = &H80000008&
Height = 255
Left = 6000
TabIndex = 6
Top = 120
Width = 1815
End
Begin VB.Label lblFile
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "数据库列表"
ForeColor = &H80000008&
Height = 255
Left = 3840
TabIndex = 4
Top = 120
Width = 2415
End
Begin VB.Label lblDir
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "选择目录"
ForeColor = &H80000008&
Height = 255
Left = 1440
TabIndex = 1
Top = 120
Width = 2295
End
Begin VB.Label lblDrive
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "选择驱动器"
ForeColor = &H80000008&
Height = 255
Left = 120
TabIndex = 0
Top = 120
Width = 1215
End
Begin VB.Menu mnuDB
Caption = "数据库"
End
Begin VB.Menu mnuFL
Caption = "数据文件"
End
Begin VB.Menu mnuExit
Caption = "退出"
End
End
Attribute VB_Name = "frmFileList"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'frmFileList窗体
'使用文件系统对象
'在选择驱动器和目录之后,显示数据库文件或数据文件
'包括文件名和大小
Option Explicit
Dim strType As String
Dim objA As New FileSystemObject
Dim objB As File
Private Sub Form_Load()
strType = "MDB" '缺省时是数据库文件
For Each objB In objA.GetFolder(Dir1.Path).Files
If UCase(objA.GetExtensionName(objB.Path)) = strType Then
lstDBM.AddItem objB.Name '在列表框显示文件名
lstSize.AddItem objB.Size '在列表框显示文件大小
End If
Next
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Dir1_Change()
lstDBM.Clear
lstSize.Clear
For Each objB In objA.GetFolder(Dir1.Path).Files
If UCase(objA.GetExtensionName(objB.Path)) = strType Then
lstDBM.AddItem objB.Name
lstSize.AddItem objB.Size
End If
Next
End Sub
Private Sub mnuDB_Click()
lblFile.Caption = "数据库列表"
lblSize.Caption = "数据库大小(字节)"
strType = "MDB"
lstDBM.Clear
lstSize.Clear
For Each objB In objA.GetFolder(Dir1.Path).Files
If UCase(objA.GetExtensionName(objB.Path)) = strType Then
lstDBM.AddItem objB.Name
lstSize.AddItem objB.Size
End If
Next
End Sub
Private Sub mnuFL_Click()
lblFile.Caption = "数据文件列表"
lblSize.Caption = "数据文件大小(字节)"
strType = "DAT"
lstDBM.Clear
lstSize.Clear
For Each objB In objA.GetFolder(Dir1.Path).Files
If UCase(objA.GetExtensionName(objB.Path)) = strType Then
lstDBM.AddItem objB.Name
lstSize.AddItem objB.Size
End If
Next
End Sub
Private Sub mnuExit_Click()
Unload Me
frmDatabase.Show
End Sub