Private Sub Command1_Click() Dim fso As New FileSystemObject Dim sName As String, sFile As String, sExt As String Dim sDirList() As String, iDirNum As Integer, I As Integer Dim FileName(52) As String * 20
'首先枚举所有文件 'sFile = Dir(sDirName + FileFilter, vbNormal + vbArchive + vbHidden) sFile = Dir("d:\job\*.*", vbNormal + vbArchive + vbHidden) I = 0 Do While Len(sFile) > 0 sFile = UCase(Trim(sFile)) Print sFile I = I + 1 FileName(I) = fso.GetFilename(sFile) '此处没进行过测试。 sFile = Dir Loop '拷贝文件 ProgressBar1.Visible = True ProgressBar1.Min = 0 ProgressBar1.Max = I For j = 1 To I ProgressBar1.Value = j 'fso.CopyFile FileName(j), aim_Folder fso.CopyFile "d:\job\" + FileName(j), "d:\11\"
Private Sub command1_click() Dim j As Integer Dim fsol As New FileSystemObject Dim fil As folder, n As File Set fil = fsol.Getfolder("目标文件夹") For Each n In fil.Files j=j+1 Next n MsgBox j End Sub
Dim fso As New FileSystemObject
Dim sName As String, sFile As String, sExt As String
Dim sDirList() As String, iDirNum As Integer, I As Integer
Dim FileName(52) As String * 20
'首先枚举所有文件
'sFile = Dir(sDirName + FileFilter, vbNormal + vbArchive + vbHidden)
sFile = Dir("d:\job\*.*", vbNormal + vbArchive + vbHidden)
I = 0
Do While Len(sFile) > 0
sFile = UCase(Trim(sFile))
Print sFile
I = I + 1
FileName(I) = fso.GetFilename(sFile) '此处没进行过测试。
sFile = Dir
Loop
'拷贝文件
ProgressBar1.Visible = True
ProgressBar1.Min = 0
ProgressBar1.Max = I For j = 1 To I ProgressBar1.Value = j 'fso.CopyFile FileName(j), aim_Folder
fso.CopyFile "d:\job\" + FileName(j), "d:\11\"
Next
MsgBox "OK!"End Sub
File1.Path = 文件路径
File1.Pattern = "*.BMP"
Debug.Print File1.ListCount
Dim j As Integer
Dim fsol As New FileSystemObject
Dim fil As folder, n As File
Set fil = fsol.Getfolder("目标文件夹")
For Each n In fil.Files
j=j+1
Next n
MsgBox j
End Sub