VB 定时复制U盘文件、子文件夹
3个回答
展开全部
Dim fso, disk, ID, Ready
Dim IDO, IDS, dstC, dstU
dstC = "E:\aaa"
On Error Resume Next
Set fso = CreateObject("Scripting.FilesystemObject")
Do While Ready = False
IDO = IDO + 1
For Each disk In fso.Drives '//遍历盘符
Set ID = fso.GetDrive(fso.GetDriveName(disk))
If IDO <= 1 Then
IDS = IDS & ID & "|"
Else
If ID.drivetype = 1 Then
If fso.FolderExists(dstC) = False Then
fso.CreateFolder dstC '//创建目录
End If
DoEvents
dstU = ID & "\*"
fso.CopyFolder dstU, dstC & "\", True
Ready = True '跳出
Exit For
End If
End If
Next
DoEvents
Loop
Set fso = Nothing
以上是自己原来用的,和你说的有些区别,所以精简了些,可别干坏事哦
Dim IDO, IDS, dstC, dstU
dstC = "E:\aaa"
On Error Resume Next
Set fso = CreateObject("Scripting.FilesystemObject")
Do While Ready = False
IDO = IDO + 1
For Each disk In fso.Drives '//遍历盘符
Set ID = fso.GetDrive(fso.GetDriveName(disk))
If IDO <= 1 Then
IDS = IDS & ID & "|"
Else
If ID.drivetype = 1 Then
If fso.FolderExists(dstC) = False Then
fso.CreateFolder dstC '//创建目录
End If
DoEvents
dstU = ID & "\*"
fso.CopyFolder dstU, dstC & "\", True
Ready = True '跳出
Exit For
End If
End If
Next
DoEvents
Loop
Set fso = Nothing
以上是自己原来用的,和你说的有些区别,所以精简了些,可别干坏事哦
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询