【发布时间】:2021-11-06 22:42:47
【问题描述】:
如何为今天和明天创建的文件添加文件创建日期过滤器?
这部分不起作用,我需要添加今天和明天创建的文件:
.Where(Function(file) New FileInfo(file).CreationTime.Date = DateTime.Today.Date)
Dim pdfList As String() = _
Directory.GetFiles(sourceDir, "*.PDF").Where(Function(file) New
FileInfo(file).CreationTime.Date = _
DateTime.Today.Date)
For Each f As String In pdfList
'Remove path from the file name.
Dim fName As String = f.Substring(sourceDir.Length + 1)
' Use the Path.Combine method to safely append the file name to the path.
' Will overwrite if the destination file already exists.
File.Copy(Path.Combine(sourceDir, fName), Path.Combine(backupDir, _
fName), True)
Next
【问题讨论】:
-
A
Date值具有增加时间以在过去或将来获得另一个Date的方法,例如Date.Today.AddDays(1)会给你明天的日期,Date.Today.AddDays(-1)会给你昨天的日期。
标签: vb.net forms winforms filesystems