虽然自己不会递归文件,但这段代码可以做到二级目录的文件,已经够用了,谢谢高人指点。现在把自己写的代码贴出来,希望有人可以改进一下就更好了!
Dim k As New System.IO.DirectoryInfo(Tables("表c").current("第一列") )
Dim dirs As String() =System.IO.Directory.GetDirectories(Tables("表c").current("第一列") )
For Each n As String In dirs
Dim w As New System.IO.DirectoryInfo(n)
Dim v As System.IO.FileInfo
For Each v In w.GetFiles
s2=s2+v.length
t2=s2
Next
Dim d As New System.IO.DirectoryInfo(Tables("表c").current("第一列") )
Dim s As Long
Dim t As Long
Dim sum As Long
Dim s2 As Long
Dim t2 As Long
Dim f As System.IO.FileInfo
For Each f In d.GetFiles
s=s+f.length
t=s
Next
Next
sum=t+t2
Dim t4 As Long
Dim allDrives() As System.IO.DriveInfo = System.IO.DriveInfo.GetDrives()
Dim d3 As System.IO.DriveInfo
For Each d3 In allDrives
If d3.drivetype = 2 Then
t4=d3.AvailableFreeSpace
End If
Next
If sum < t4 Then
Forms("等待窗口").open()
Application.DoEvents
FileSys.CopyDirectory (Tables("表c").current("第一列") , Tables("表c").current("第二列") ,True)
Forms("等待窗口").close()
MessageBox.show("复制成功")
Else
MessageBox.show("磁盘空间不足")
End If
[此贴子已经被作者于2014-11-5 19:05:23编辑过]