Dim y,m,d As Integer Dim dFile As New List(Of String) Dim drs,drs2 As List (of DataRow) drs2=DataTables("备份").Select("[备份类型]='账套备份'") For Each dr2 As DataRow In drs2 Dim namelen As Integer=dr2("备份计划名称").Length Dim filelen As Integer=dr2("备份路径").Length For Each File As String In FileSys.GetFiles(dr2("备份路径")) If File.SubString(filelen,namelen)=dr2("备份计划名称") Then Dim ifo As new FileInfo(file) Dim sp As TimeSpan = Date.Now - ifo.CreationTime If sp.TotalDays>=dr2("删除旧备份天数") Then '如果距离上次备份已经超过天数的部分 dFile.Add(File) End If End If Next Next For Each f As string In dFile FileSys.DeleteFile(f,2,2) Next
|