调用Scripting.FileSystemObject对象就可以了 下面是例程 Sub ShowFileList(folderspec) Dim fs, f, f1, fc, s Dim i As Integer
Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder(folderspec) Set fc = f.Files i = fc.Count For Each f1 In fc s = s & f1.Name s = s & vbCrLf Next MsgBox s End Sub
晕,内部控件就行了FileListBox1.Path="D:\Test" Debug.Print FileListBox1.ListCount 返回文件总数当然,要注意ReadOnly System Pattern 等属性的设置,合理运用会很方便的
下面是例程
Sub ShowFileList(folderspec)
Dim fs, f, f1, fc, s
Dim i As Integer
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.Files
i = fc.Count
For Each f1 In fc
s = s & f1.Name
s = s & vbCrLf
Next
MsgBox s
End Sub
Debug.Print FileListBox1.ListCount 返回文件总数当然,要注意ReadOnly System Pattern 等属性的设置,合理运用会很方便的