【发布时间】:2012-05-30 19:09:03
【问题描述】:
我正在开发一个程序,以便在文件老化一定时间后从某个文件夹中删除文件,并通过正则表达式或扩展名进行匹配。我遇到了一个问题,其中 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 一样多的文件。这将创建冗余的数据库记录,这是不希望的。有没有办法判断是否 ALL 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
【问题讨论】:
-
你不能只看File.GetLastWriteTime吗?
标签: arrays vb.net ssis filesystems