开发者

Force update file timestamp in VB.net

开发者 https://www.devze.com 2023-03-04 04:37 出处:网络
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 the

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消