在D盘下建一个test文件夹,里面有5个文件1.txt,2.txt,3.txt,4.txt,5.txt Dim fso As FileSystemObject Dim x As Files Dim y As File Dim a(100) As String Dim z, q As Integer Private Sub Command1_Click() Set fso = CreateObject("scripting.filesystemobject") Set x = fso.GetFolder("D:\test\").Files For Each y In x a(z) = y.Name z = z + 1 Next For q = 0 To 100 '以下测试是否存进数组 Print a(q) Next q End SubPrivate Sub Form_Load() z = 0 End Sub
For Each foundfile As String In My.Computer.FileSystem.GetFiles("d:\") foundfile = foundfile & vbCrLf My.Computer.FileSystem.WriteAllText("D:\FILELIST.TXT", foundfile, True) Next
CommonDialog1.MaxFileSize = 1024
CommonDialog1.ShowOpen
s = CommonDialog1.FileName
这样CommonDialog1就可以多选了
Dim fso As FileSystemObject
Dim x As Files
Dim y As File
Dim a(100) As String
Dim z, q As Integer
Private Sub Command1_Click()
Set fso = CreateObject("scripting.filesystemobject")
Set x = fso.GetFolder("D:\test\").Files
For Each y In x
a(z) = y.Name
z = z + 1
Next
For q = 0 To 100 '以下测试是否存进数组
Print a(q)
Next q
End SubPrivate Sub Form_Load()
z = 0
End Sub
foundfile = foundfile & vbCrLf
My.Computer.FileSystem.WriteAllText("D:\FILELIST.TXT", foundfile, True)
Next