Force update file timestamp in VB.net
I am using the following code to copy a file:
System.IO.File.Copy(strOldFile, strNewFile)
But the trouble is that the newly开发者_运维知识库-created file inherits the old file's timestamp. Is there a way to force the timestamp to update?
You can edit the CreationTime using the FileInfo class.
Dim path = Path.GetTempFileName();
Dim fi As New FileInfo(path)
fi.CreationTime = DateTime.Now;
fi.LastWriteTime = DateTime.Now;
精彩评论