简体   繁体   中英

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM