Praveen
Praveen

Reputation: 56509

How to get file generation datetime and updated datetime in C#

I am trying to generate files and perform write operation in a scheduled process. I need to find out the time taken to generate the files (after write operation is performed). I am little confused in this operation. Can anyone help on this.

Thanks in advance.

Upvotes: 0

Views: 74

Answers (1)

Habib
Habib

Reputation: 223322

You can get the CreationTime and LastWriteTime and find their differences.

FileInfo file = new FileInfo("C:\test.text");
Console.WriteLine(file.LastWriteTime);
Console.WriteLine(file.CreationTime);

var timeTaken = file.LastWriteTime - file.CreationTime;

Upvotes: 1

Related Questions