Sub ShowFolderList(ByVal mvDrive As String, ByVal mvPath As String) If Right(mvPath, 10) <> "|NONE|HERE" Then
Dim fs, f, f1, fc, s Dim mvFound As Boolean
mvFound = False Set fs = CreateObject("Scripting.FileSystemObject") If mvPath = "main" Then mvPath = "" End If Set f = fs.GetFolder(mvDrive & mvPath) Set fc = f.SubFolders
If mvPath = "" Then trvDriveView.Nodes.Add "main", tvwChild, "|NONE|HERE", "当前路径没有文件夹!" Else trvDriveView.Nodes.Add mvPath, tvwChild, mvPath & "\|NONE|HERE", "当前路径没有文件夹!" End If
End If End If End Sub
文件个数: dim fso set fso=createobject("Scripting.FilesystemObject") debug.print fso.getfolder("c:\temp").files.count set fso=nothing
Dim fs, f, f1, fc, s
Dim mvFound As Boolean
mvFound = False
Set fs = CreateObject("Scripting.FileSystemObject")
If mvPath = "main" Then
mvPath = ""
End If
Set f = fs.GetFolder(mvDrive & mvPath)
Set fc = f.SubFolders
For Each f1 In fc
mvFound = True
If mvPath = "" Then
trvDriveView.Nodes.Add "main", tvwChild, f1.Name, f1.Name & " (" & Format((f1.Size / 1024) / 1024, "#0.00") & " MB)"
Else
trvDriveView.Nodes.Add mvPath, tvwChild, mvPath & "\" & f1.Name, f1.Name & " (" & Format((f1.Size / 1024) / 1024, "#0.00") & " MB)"
End If
trvDriveView.Refresh
Next
If mvFound = False Then
If mvPath = "" Then
trvDriveView.Nodes.Add "main", tvwChild, "|NONE|HERE", "当前路径没有文件夹!"
Else
trvDriveView.Nodes.Add mvPath, tvwChild, mvPath & "\|NONE|HERE", "当前路径没有文件夹!"
End If
End If
End If
End Sub
dim fso
set fso=createobject("Scripting.FilesystemObject")
debug.print fso.getfolder("c:\temp").files.count
set fso=nothing