Urbycoz
Urbycoz

Reputation: 7421

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?

Upvotes: 0

Views: 1248

Answers (1)

RB.
RB.

Reputation: 37182

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;

Upvotes: 4

Related Questions