小白求助!如何把一个文件夹下面的文件复制到多个文件夹下面
比如我要把“D:/a”文件下面的所有文件复制到文件夹“E:/1” ,文件夹“E:/2”,文件夹“E:/3”,文件夹“E:/4”,文件夹“E:/5”.....很多个文件夹里
添加一个FileListBox控件,用来提取文件夹中所有的文件;
设置好源文件和目标文件路径,用FileCopy复制文件。
代码如下:
Option Explicit
Private Sub Form_Load()
File1.Path = "D:\a"
End Sub
Private Sub Command1_Click()
Dim i As Integer
Dim j As Integer
Dim N As Integer
Dim oldPath As String
Dim newPath() As String
oldPath = "D:\a"
N = 4
ReDim newPath(1 To N)
For i = 1 To N
newPath(i) = "E:\" & i
Next
For i = 1 To N
For j = 0 To File1.ListCount - 1
FileSystem.FileCopy oldPath & "\" & File1.List(j), newPath(i) & "\" & File1.List(j)
Next
Next
End Sub