我正在开发一个程序,以在文件老化一定时间后从某个文件夹中删除文件,并通过正则表达式或扩展名匹配。我遇到了 files() 可能存在的问题
files(0) = Nothing
files(1) = Nothing
files(2) = Nothing
ect....
现在它的写法,我可以放置
Else
log(1) = data(1)
log(3) = "Array field empty"
InsertLog(log)
file(i) = Nothing
并且该程序将记录与保留一样多的文件。这将创建冗余的数据库记录并且是不想要的。有没有办法确定是否全部files(i) = Nothing
,然后将代码放入其中以插入数据库?
'If log(3) is successful that means no files were old enough or deleted successfully
If log(3) = "Success" And IsArray(files) Then
For Each file In files
If Not file.IsNullOrEmpty(file) Then
'If files is actually something insert into the log
log(1) = file
InsertLog(log)
'could place else here
End If
Next
files = Nothing
Else
'If no files or error in directory perform this
log(1) = data(1)
InsertLog(log)
End If