If filesys.directoryexists(args0) = False OrElse filesys.directoryexists(args1)
= False Then Return Nothing
For Each fns
As String In filesys.GetFiles(args0) 'fileNameSource
Dim fnt As String = args1 & "\"
& filesys.GetName(fns) 'fileNameTarget
If filesys.FileExists(fnt) = False Then
output.show("step1")
filesys.copyfile(fns,fnt)
Else '比较修改时间
Dim fis As new fileinfo(fns) 'fileinfoSource
Dim fist As Date = fis.lastwritetime 'fileinfoSourceTime
Dim fit As new fileinfo(fnt) 'fileinfoTarget
Dim fitt As Date = fit.lastwritetime 'fileinfoTargetTime
If fitt < fist Then
filesys.copyfile(fns,fnt,True)
End If
End If
Next
'子文件夹
For Each fns
As String In filesys.GetDirectories(args0)
'fileNameSource
dim fnt as string = agrs(1) & fnt.replace(args(0),"")
Functions.Execute(fns,fnt) '递归调用本身
next
Return Nothing
需要时就调用 Functions.Execute("backup","p:\desktop\Foxtable项目\备份资料\source","p:\desktop\Foxtable项目\备份资料\target")
可是总是出错,求高手完善一下。
另,曾尝试FileSys.CopyDirectory完成此功能,但它没有判断新旧文件编辑时间的功能。源文件夹已删除而目标文件夹还有的文件夹怎样删除?这个功能也没有。